{"record":{"id":"0ee4bca6addf8a78","repo":"larksuite/cli","slug":"exec-provider-failed-to-marshal-request-w","errorCode":null,"errorMessage":"exec provider: failed to marshal request: %w","messagePattern":"exec provider: failed to marshal request: %w","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"internal/binding/secret_resolve_exec.go","lineNumber":114,"sourceCode":"\t\tMaxOut:  maxOut,\n\t}, nil\n}\n\n// marshalExecRequest encodes the JSON protocol request sent to the child.\n// providerName is supplied by resolveSecretRef after consulting\n// secrets.defaults.exec; an empty value falls back to DefaultProviderAlias\n// so the function can still be reasoned about in isolation.\nfunc marshalExecRequest(ref *SecretRef, providerName string) ([]byte, error) {\n\tif providerName == \"\" {\n\t\tproviderName = DefaultProviderAlias\n\t}\n\tdata, err := json.Marshal(execRequest{\n\t\tProtocolVersion: 1,\n\t\tProvider:        providerName,\n\t\tIDs:             []string{ref.ID},\n\t})\n\tif err != nil {\n\t\treturn nil, fmt.Errorf(\"exec provider: failed to marshal request: %w\", err)\n\t}\n\treturn data, nil\n}\n\n// buildExecEnv assembles the child's environment: only variables listed in\n// pc.PassEnv (and non-empty in the parent) plus pc.Env entries. The child\n// never inherits the full parent env — always set cmd.Env explicitly.\nfunc buildExecEnv(pc *ProviderConfig, getenv func(string) string) []string {\n\tenv := make([]string, 0, len(pc.PassEnv)+len(pc.Env))\n\tfor _, key := range pc.PassEnv {\n\t\tif val := getenv(key); val != \"\" {\n\t\t\tenv = append(env, key+\"=\"+val)\n\t\t}\n\t}\n\tfor key, val := range pc.Env {\n\t\tenv = append(env, key+\"=\"+val)\n\t}\n\treturn env","sourceCodeStart":96,"sourceCodeEnd":132,"githubUrl":"https://github.com/larksuite/cli/blob/7fd6ef3c07182257ce776cdc5a614e122d5bd4b3/internal/binding/secret_resolve_exec.go#L96-L132","documentation":"marshalExecRequest serializes the exec provider's JSON request (protocol version, provider name, and the secret IDs) before spawning the child process. It wraps any json.Marshal failure with this message. In practice this is nearly unreachable because execRequest contains only plain string/int fields, so a failure indicates a programming or memory error rather than user input.","triggerScenarios":"prepareExecRun -> marshalExecRequest calls json.Marshal on the execRequest struct and json.Marshal returns a non-nil error (e.g. unsupported type if the struct ever gains an unmarshalable field such as chan/func, or an out-of-memory condition).","commonSituations":"Essentially only seen after modifying execRequest to include an unsupported field type (channel, func, cyclic pointer) — stock users should never hit this; could surface as an internal error during secret resolution with no user-actionable input.","solutions":["Check the wrapped cause: if it mentions an unsupported type, inspect recent changes to the execRequest struct in secret_resolve_exec.go and revert or fix the field type","If it appeared after a library upgrade, report/inspect the version change for struct changes","Retry the operation once in case of a transient memory error; if it persists, file a bug with the wrapped error"],"exampleFix":"// before (unsupported field added to execRequest)\ntype execRequest struct {\n    ProtocolVersion int\n    Provider string\n    IDs []string\n    Callback func() // json.Marshal fails\n}\n\n// after\ntype execRequest struct {\n    ProtocolVersion int\n    Provider string\n    IDs []string\n}","handlingStrategy":"try-catch","validationCode":null,"typeGuard":null,"tryCatchPattern":"secret, err := resolveSecretRef(ctx, ref)\nif err != nil {\n    if strings.Contains(err.Error(), \"failed to marshal request\") {\n        return fmt.Errorf(\"internal exec-provider request serialization failed: %w\", err)\n    }\n    return err\n}","preventionTips":["Don't add chan/func/cyclic-pointer fields to the execRequest struct without a custom MarshalJSON","Keep execRequest limited to JSON-primitive fields","If it occurs after a library upgrade, capture the wrapped error and report it — it signals a library bug, not user error"],"tags":["json","secrets","internal"],"backgroundTag":"json-marshal-failed","analyzedSha":"7fd6ef3c07182257ce776cdc5a614e122d5bd4b3","analyzedAt":"2026-09-04T21:17:44.649Z","contentChangedAt":"2026-09-04T21:17:44.649Z","schemaVersion":2},"datasetVersion":"2026-09-12T02:17:10.037Z"}