{"record":{"id":"3229be5951577a73","repo":"lima-vm/lima","slug":"pattern-q-contains-invalid-character-q-at-posi","errorCode":null,"errorMessage":"pattern %#q contains invalid character %#q at position %d","messagePattern":"pattern %#q contains invalid character %#q at position (.+?)","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"pkg/envutil/envutil.go","lineNumber":52,"sourceCode":"\t\"SSH_*\",\n\t\"TERM\",\n\t\"TERMINFO\",\n\t\"TMPDIR\",\n\t\"UID\",\n\t\"USER\",\n\t\"XAUTHORITY\",\n\t\"XDG_*\",\n\t\"ZDOTDIR\",\n\t\"ZSH*\",\n\t\"_*\", // Variables starting with underscore are typically internal\n}\n\nfunc validatePattern(pattern string) error {\n\tinvalidChar := regexp.MustCompile(`([^a-zA-Z0-9_*])`)\n\tif matches := invalidChar.FindStringSubmatch(pattern); matches != nil {\n\t\tinvalidCharacter := matches[1]\n\t\tpos := strings.Index(pattern, invalidCharacter)\n\t\treturn fmt.Errorf(\"pattern %#q contains invalid character %#q at position %d\",\n\t\t\tpattern, invalidCharacter, pos)\n\t}\n\treturn nil\n}\n\n// getBlockList returns the list of environment variable patterns to be blocked.\nfunc getBlockList() []string {\n\tblockEnv := os.Getenv(\"LIMA_SHELLENV_BLOCK\")\n\tif blockEnv == \"\" {\n\t\treturn defaultBlockList\n\t}\n\n\tshouldAppend := strings.HasPrefix(blockEnv, \"+\")\n\tpatterns := parseEnvList(strings.TrimPrefix(blockEnv, \"+\"))\n\n\tfor _, pattern := range patterns {\n\t\tif err := validatePattern(pattern); err != nil {\n\t\t\tlogrus.Fatalf(\"Invalid LIMA_SHELLENV_BLOCK pattern: %v\", err)","sourceCodeStart":34,"sourceCodeEnd":70,"githubUrl":"https://github.com/lima-vm/lima/blob/dd909d0973cd84fa35f9e1693181b4585ea616c1/pkg/envutil/envutil.go#L34-L70","documentation":"validatePattern checks that environment-variable glob patterns in block/allow lists contain only [a-zA-Z0-9_*]; any other character makes the whole pattern invalid. It returns the offending character and its 1-based-index offset (position of first match) so the user can fix their LIMA_BLOCK/ALLOW list entries.","triggerScenarios":"Calling getBlockList / getAllowList (i.e. lima env-variable filtering) when an entry in the block or allow list contains characters outside letters, digits, underscore, and `*` — e.g. `FOO?BAR`, `FO[O]`, or a stray comma/space.","commonSituations":"Typos in wildcard patterns in _LIMA_BLOCK_ENV / allow config; copying shell glob syntax like `?` or character classes; accidental whitespace or separators inside a list entry.","solutions":["Replace invalid characters with `*` wildcards or remove them, e.g. `FO?BAR` → `FO*BAR`","Use only allowed chars: letters, digits, `_`, and `*`","Check the reported position number in the error to locate the bad character in the pattern","Re-check list separators — entries must be split correctly, not contain embedded delimiters"],"exampleFix":"// before\npattern: \"FOO?BAR\"  // invalid character '?' at position 3\n// after\npattern: \"FOO*BAR\"","handlingStrategy":"validation","validationCode":"var validPattern = regexp.MustCompile(`^[a-zA-Z0-9_*]+$`)\nfunc validEnvPattern(p string) bool { return validPattern.MatchString(p) }\n// check each entry before use\nfor _, p := range patterns {\n    if !validEnvPattern(p) { return fmt.Errorf(\"invalid pattern %q\", p) }\n}","typeGuard":null,"tryCatchPattern":"if err := envutil.ValidatePattern(p); err != nil {\n    // parse position from error and fix the pattern before retry\n    return fmt.Errorf(\"fix block/allow list entry: %w\", err)\n}","preventionTips":["Use only letters, digits, `_` and `*` in env patterns","Never use shell glob syntax like ? or [ ] in lima env patterns","Validate config lists after edits before applying them","Split list entries correctly to avoid embedded separators"],"tags":["validation","glob-pattern","environment"],"backgroundTag":"invalid-glob-pattern","analyzedSha":"dd909d0973cd84fa35f9e1693181b4585ea616c1","analyzedAt":"2026-09-01T14:24:59.842Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-08T10:18:20.063Z"}