{"id":"eee632a6373e6017","repo":"docker/cli","slug":"context-name-q-is-invalid-names-are-validated-ag","errorCode":null,"errorMessage":"context name %q is invalid, names are validated against regexp %q","messagePattern":"context name %q is invalid, names are validated against regexp %q","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"cli/context/store/store.go","lineNumber":224,"sourceCode":"// GetStorageInfo returns the paths where the Metadata and TLS data are stored\n// for the context.\nfunc (s *ContextStore) GetStorageInfo(contextName string) StorageInfo {\n\treturn StorageInfo{\n\t\tMetadataPath: s.meta.contextDir(contextdirOf(contextName)),\n\t\tTLSPath:      s.tls.contextDir(contextName),\n\t}\n}\n\n// ValidateContextName checks a context name is valid.\nfunc ValidateContextName(name string) error {\n\tif name == \"\" {\n\t\treturn errors.New(\"context name cannot be empty\")\n\t}\n\tif name == \"default\" {\n\t\treturn errors.New(`\"default\" is a reserved context name`)\n\t}\n\tif !isValidName(name) {\n\t\treturn fmt.Errorf(\"context name %q is invalid, names are validated against regexp %q\", name, validNameFormat)\n\t}\n\treturn nil\n}\n\n// validNameFormat is used as part of errors for invalid context-names.\n// We should consider making this less technical (\"must start with \"a-z\",\n// and only consist of alphanumeric characters and separators\").\nconst validNameFormat = `^[a-zA-Z0-9][a-zA-Z0-9_.+-]+$`\n\n// isValidName checks if the context-name is valid (\"^[a-zA-Z0-9][a-zA-Z0-9_.+-]+$\").\n//\n// Names must start with an alphanumeric character (a-zA-Z0-9), followed by\n// alphanumeric or separators (\"_\", \".\", \"+\", \"-\").\nfunc isValidName(s string) bool {\n\tif len(s) < 2 || !isAlphaNum(s[0]) {\n\t\treturn false\n\t}\n","sourceCodeStart":206,"sourceCodeEnd":242,"githubUrl":"https://github.com/docker/cli/blob/e9452d6e785f6e365712b9d71bd7517591773c86/cli/context/store/store.go#L206-L242","documentation":"Error \"context name %q is invalid, names are validated against regexp %q\" thrown in docker/cli.","triggerScenarios":"Thrown at cli/context/store/store.go:224 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":[],"exampleFix":null,"handlingStrategy":null,"validationCode":null,"typeGuard":null,"tryCatchPattern":null,"preventionTips":[],"tags":[],"analyzedSha":"e9452d6e785f6e365712b9d71bd7517591773c86","analyzedAt":"2026-08-01T07:09:22.474Z","schemaVersion":2}