{"record":{"id":"92b7e8cccf486dec","repo":"Tencent/WeKnora","slug":"invalid-s-value-q-expected-q-or-q","errorCode":null,"errorMessage":"invalid %s value %q: expected %q or %q","messagePattern":"invalid (.+?) value %q: expected %q or %q","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"internal/storageurl/mode.go","lineNumber":77,"sourceCode":"\tif ctx == nil {\n\t\treturn false\n\t}\n\tforced, _ := ctx.Value(forcedHandleKey{}).(bool)\n\treturn forced\n}\n\n// ParseMode validates a mode supplied by a client or by configuration. An empty\n// value yields ModeHandle so an unset parameter or setting keeps the default.\nfunc ParseMode(raw string) (Mode, error) {\n\tswitch Mode(strings.ToLower(strings.TrimSpace(raw))) {\n\tcase \"\":\n\t\treturn ModeHandle, nil\n\tcase ModeHandle:\n\t\treturn ModeHandle, nil\n\tcase ModePublic:\n\t\treturn ModePublic, nil\n\tdefault:\n\t\treturn ModeHandle, fmt.Errorf(\n\t\t\t\"invalid %s value %q: expected %q or %q\", QueryParam, raw, ModeHandle, ModePublic)\n\t}\n}\n\n// badDefault keeps a misconfigured EnvVar to a single log line per distinct bad\n// value instead of one per request, while still warning again if an operator\n// rolls out a second typo. The value itself is re-read every time so a fix takes\n// effect without a restart.\nvar badDefault struct {\n\tsync.Mutex\n\twarned map[string]bool\n}\n\nfunc warnBadDefaultOnce(ctx context.Context, raw string, err error) {\n\tbadDefault.Lock()\n\tdefer badDefault.Unlock()\n\tif badDefault.warned[raw] {\n\t\treturn","sourceCodeStart":59,"sourceCodeEnd":95,"githubUrl":"https://github.com/Tencent/WeKnora/blob/988cbb03305e055d8ebb7d46d9ac6cc0803cd074/internal/storageurl/mode.go#L59-L95","documentation":"Thrown by ParseMode in internal/storageurl/mode.go when a client- or config-supplied storage URL mode value is neither empty (default ModeHandle), 'handle', nor 'public'. The raw untrimmed value is echoed in the message; callers fail closed rather than guessing a mode.","triggerScenarios":"Thrown at internal/storageurl/mode.go:77 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":["Set the mode to 'handle' or 'public' (case-insensitive)","Remove the parameter entirely to accept the default ModeHandle","Fix configuration values that carry typos or extra characters"],"exampleFix":null,"handlingStrategy":"validation","validationCode":null,"typeGuard":null,"tryCatchPattern":null,"preventionTips":[],"tags":[],"backgroundTag":null,"analyzedSha":"988cbb03305e055d8ebb7d46d9ac6cc0803cd074","analyzedAt":"2026-09-02T14:41:08.344Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-08T10:18:20.063Z"}