{"record":{"id":"14cb15db1a1a4c57","repo":"Tencent/WeKnora","slug":"unsupported-timeout-mode-q","errorCode":null,"errorMessage":"unsupported timeout mode %q","messagePattern":"unsupported timeout mode %q","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"internal/sandbox/cube_remote_client.go","lineNumber":941,"sourceCode":"\tlower := strings.ToLower(err.Error())\n\treturn strings.Contains(lower, \"not found\") ||\n\t\tstrings.Contains(lower, \"no such file\") ||\n\t\tstrings.Contains(lower, \"sandbox_not_found\") ||\n\t\tstrings.Contains(lower, \"http 404\")\n}\n\nfunc cubeTimeout(policy RemoteTimeoutPolicy) (*time.Duration, error) {\n\tswitch policy.Mode {\n\tcase \"\", RemoteTimeoutServerDefault:\n\t\treturn nil, nil\n\tcase RemoteTimeoutExplicit:\n\t\tvalue := policy.Value\n\t\tif value < 0 {\n\t\t\tvalue = cubesandbox.NeverTimeout\n\t\t}\n\t\treturn &value, nil\n\tdefault:\n\t\treturn nil, fmt.Errorf(\"unsupported timeout mode %q\", policy.Mode)\n\t}\n}\n\n// cubeHandleSandbox extracts the SDK *cubesandbox.Sandbox from an opaque\n// RemoteSandboxHandle. Returns an error when the handle is nil, not Cube,\n// or has an empty sandbox ID.\nfunc cubeHandleSandbox(op string, handle RemoteSandboxHandle) (*cubesandbox.Sandbox, error) {\n\tcubeHandle, ok := handle.(*cubeRemoteHandle)\n\tif !ok || cubeHandle == nil || cubeHandle.sb == nil ||\n\t\tstrings.TrimSpace(cubeHandle.sb.SandboxID) == \"\" {\n\t\treturn nil, cubeInvalidRequest(op, \"handle was not issued by Cube\", nil)\n\t}\n\treturn cubeHandle.sb, nil\n}\n\n// cubeRemoteSummary converts the SDK's SandboxInfo (from List / GetInfo) into\n// the provider-neutral RemoteSandboxSummary DTO.\nfunc cubeRemoteSummary(info cubesandbox.SandboxInfo) *RemoteSandboxSummary {","sourceCodeStart":923,"sourceCodeEnd":959,"githubUrl":"https://github.com/Tencent/WeKnora/blob/988cbb03305e055d8ebb7d46d9ac6cc0803cd074/internal/sandbox/cube_remote_client.go#L923-L959","documentation":"cubeTimeout maps a timeout policy's Mode to a concrete Cube SDK timeout value. The switch handles the known modes (including a mode treated as NeverTimeout for negative values); any unrecognized Mode string reaches the default branch and produces this error, aborting Create before the sandbox is provisioned.","triggerScenarios":"Building a TimeoutPolicy with a Mode value that the mapper does not recognize (typo, renamed enum constant, stale serialized config from an older version) and calling Create, which resolves the policy via cubeTimeout.","commonSituations":"Hand-writing a policy mode string instead of using the exported constants; a config file persisted by an older library version whose mode names changed; copy-pasting policy YAML from another sandbox backend with different mode vocabulary.","solutions":["Set policy.Mode using the library's exported timeout mode constants instead of raw strings","Inspect the %q value in the error and correct it to a supported mode name","If the value came from a persisted config, re-serialize it with the current library version to migrate mode names","Check for whitespace/case differences — modes are matched exactly by the switch"],"exampleFix":"// before\npolicy := TimeoutPolicy{Mode: \"forever\"} // unknown mode\n// after\npolicy := TimeoutPolicy{Mode: TimeoutModeNever} // use exported constant; NeverTimeout applies for negative values","handlingStrategy":"validation","validationCode":"switch policy.Mode {\ncase TimeoutModeFixed, TimeoutModeNever, TimeoutModeDefault:\ndefault:\n    return fmt.Errorf(\"unknown timeout mode %q before calling Create\", policy.Mode)\n}","typeGuard":"func isKnownTimeoutMode(m TimeoutMode) bool {\n    switch m { case TimeoutModeFixed, TimeoutModeNever, TimeoutModeDefault: return true }\n    return false\n}","tryCatchPattern":"sb, err := client.Create(ctx, spec)\nif err != nil {\n    if strings.Contains(err.Error(), \"unsupported timeout mode\") { /* fix policy.Mode to an exported constant */ }\n    return err\n}","preventionTips":["Always construct TimeoutPolicy with exported mode constants, never raw strings","Re-serialize old persisted configs with the current library version to migrate mode names","Validate policy modes in a unit test before sandbox provisioning paths run"],"tags":["sandbox","timeout","configuration","enum"],"backgroundTag":"invalid-enum-value","analyzedSha":"988cbb03305e055d8ebb7d46d9ac6cc0803cd074","analyzedAt":"2026-09-02T14:41:08.344Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-08T10:18:20.063Z"}