Skip to content

Commit a93dc5a

Browse files
authored
Add app name validation and improve appkit template docs (#4031)
Fixes based on agent trajectory analysis to reduce common errors: **Validation:** - Add app name length validation in init-template command - Prevents deployment failures from names exceeding 30 chars (dev-<name>) - Clear error messages with max length guidance **Documentation improvements in CLAUDE.md:** - Document TypeScript verbatimModuleSyntax requirement (import type usage) - Clarify useAnalyticsQuery API - no enabled/refetch options available - Add guidance for updating smoke tests after app customization - Document app naming constraints with examples
1 parent 5d2570a commit a93dc5a

File tree

3 files changed

+146
-246
lines changed

3 files changed

+146
-246
lines changed

experimental/apps-mcp/cmd/init_template.go

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,20 @@ import (
1414
"github.com/spf13/cobra"
1515
)
1616

17+
func validateAppNameLength(projectName string) error {
18+
const maxAppNameLength = 30
19+
const devTargetPrefix = "dev-"
20+
totalLength := len(devTargetPrefix) + len(projectName)
21+
if totalLength > maxAppNameLength {
22+
maxAllowed := maxAppNameLength - len(devTargetPrefix)
23+
return fmt.Errorf(
24+
"app name too long: 'dev-%s' is %d chars (max: %d). App name must be ≤%d characters",
25+
projectName, totalLength, maxAppNameLength, maxAllowed,
26+
)
27+
}
28+
return nil
29+
}
30+
1731
func readClaudeMd(ctx context.Context, configFile string) {
1832
showFallback := func() {
1933
cmdio.LogString(ctx, "\nConsult with CLAUDE.md provided in the bundle if present.")
@@ -109,6 +123,19 @@ See https://docs.databricks.com/en/dev-tools/bundles/templates.html for more inf
109123
return errors.New("only one of --config-file or --config-json can be specified")
110124
}
111125

126+
if configFile != "" {
127+
if configBytes, err := os.ReadFile(configFile); err == nil {
128+
var userConfigMap map[string]any
129+
if err := json.Unmarshal(configBytes, &userConfigMap); err == nil {
130+
if projectName, ok := userConfigMap["project_name"].(string); ok {
131+
if err := validateAppNameLength(projectName); err != nil {
132+
return err
133+
}
134+
}
135+
}
136+
}
137+
}
138+
112139
var templatePathOrUrl string
113140
if len(args) > 0 {
114141
templatePathOrUrl = args[0]
@@ -157,6 +184,13 @@ See https://docs.databricks.com/en/dev-tools/bundles/templates.html for more inf
157184
return fmt.Errorf("invalid JSON in --config-json: %w", err)
158185
}
159186

187+
// Validate app name length
188+
if projectName, ok := userConfigMap["project_name"].(string); ok {
189+
if err := validateAppNameLength(projectName); err != nil {
190+
return err
191+
}
192+
}
193+
160194
tmpFile, err := os.CreateTemp("", "mcp-template-config-*.json")
161195
if err != nil {
162196
return fmt.Errorf("create temp config file: %w", err)

0 commit comments

Comments
 (0)