@@ -16,6 +16,20 @@ import (
1616 "github.com/spf13/cobra"
1717)
1818
19+ func validateAppNameLength (projectName string ) error {
20+ const maxAppNameLength = 30
21+ const devTargetPrefix = "dev-"
22+ totalLength := len (devTargetPrefix ) + len (projectName )
23+ if totalLength > maxAppNameLength {
24+ maxAllowed := maxAppNameLength - len (devTargetPrefix )
25+ return fmt .Errorf (
26+ "app name too long: 'dev-%s' is %d chars (max: %d). App name must be ≤%d characters" ,
27+ projectName , totalLength , maxAppNameLength , maxAllowed ,
28+ )
29+ }
30+ return nil
31+ }
32+
1933func readClaudeMd (ctx context.Context , configFile string ) {
2034 showFallback := func () {
2135 cmdio .LogString (ctx , "\n Consult with CLAUDE.md provided in the bundle if present." )
@@ -189,6 +203,19 @@ See https://docs.databricks.com/en/dev-tools/bundles/templates.html for more inf
189203 return errors .New ("only one of --config-file or --config-json can be specified" )
190204 }
191205
206+ if configFile != "" {
207+ if configBytes , err := os .ReadFile (configFile ); err == nil {
208+ var userConfigMap map [string ]any
209+ if err := json .Unmarshal (configBytes , & userConfigMap ); err == nil {
210+ if projectName , ok := userConfigMap ["project_name" ].(string ); ok {
211+ if err := validateAppNameLength (projectName ); err != nil {
212+ return err
213+ }
214+ }
215+ }
216+ }
217+ }
218+
192219 var templatePathOrUrl string
193220 if len (args ) > 0 {
194221 templatePathOrUrl = args [0 ]
@@ -237,6 +264,13 @@ See https://docs.databricks.com/en/dev-tools/bundles/templates.html for more inf
237264 return fmt .Errorf ("invalid JSON in --config-json: %w" , err )
238265 }
239266
267+ // Validate app name length
268+ if projectName , ok := userConfigMap ["project_name" ].(string ); ok {
269+ if err := validateAppNameLength (projectName ); err != nil {
270+ return err
271+ }
272+ }
273+
240274 tmpFile , err := os .CreateTemp ("" , "mcp-template-config-*.json" )
241275 if err != nil {
242276 return fmt .Errorf ("create temp config file: %w" , err )
0 commit comments