{"record":{"id":"bb6ca7f5a22a8ffc","repo":"kopia/kopia","slug":"resolvepolicy","errorCode":null,"errorMessage":"ResolvePolicy","messagePattern":"ResolvePolicy","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"internal/serverapi/client_wrappers.go","lineNumber":196,"sourceCode":"\treturn fmt.Sprintf(\"userName=%v&host=%v&path=%v\", si.UserName, si.Host, si.Path)\n}\n\n// SetPolicy sets the policy.\nfunc SetPolicy(ctx context.Context, c *apiclient.KopiaAPIClient, si snapshot.SourceInfo, pol *policy.Policy) error {\n\tresp := &Empty{}\n\tif err := c.Put(ctx, \"policy?\"+policyTargetURLParameters(si), pol, resp); err != nil {\n\t\treturn errors.Wrap(err, \"SetPolicy\")\n\t}\n\n\treturn nil\n}\n\n// ResolvePolicy resolves the policy.\nfunc ResolvePolicy(ctx context.Context, c *apiclient.KopiaAPIClient, si snapshot.SourceInfo, req *ResolvePolicyRequest) (*ResolvePolicyResponse, error) {\n\tresp := &ResolvePolicyResponse{}\n\n\tif err := c.Post(ctx, \"policy/resolve?\"+policyTargetURLParameters(si), req, resp); err != nil {\n\t\treturn nil, errors.Wrap(err, \"ResolvePolicy\")\n\t}\n\n\treturn resp, nil\n}\n\n// ListTasks lists the tasks.\nfunc ListTasks(ctx context.Context, c *apiclient.KopiaAPIClient) (*TaskListResponse, error) {\n\tresp := &TaskListResponse{}\n\tif err := c.Get(ctx, \"tasks\", nil, resp); err != nil {\n\t\treturn nil, errors.Wrap(err, \"ListTasks\")\n\t}\n\n\treturn resp, nil\n}\n\n// GetObject returns the object payload.\nfunc GetObject(ctx context.Context, c *apiclient.KopiaAPIClient, objectID string) ([]byte, error) {\n\tvar b []byte","sourceCodeStart":178,"sourceCodeEnd":214,"githubUrl":"https://github.com/kopia/kopia/blob/82495e54b584c1ef6073c9e1be048f57f8aef078/internal/serverapi/client_wrappers.go#L178-L214","documentation":"ResolvePolicy() POSTs to 'policy/resolve?<target params>' to get the effective (merged) policy. Any request failure is wrapped as \"ResolvePolicy\". It indicates the resolve request failed rather than the policy being undefined.","triggerScenarios":"Calling serverapi.ResolvePolicy against an unreachable server, with a ResolvePolicyRequest the server rejects, or malformed target URL parameters from the SourceInfo.","commonSituations":"Anonymous test callers resolving policies before the server is connected; source paths with characters that break the query string; server without the policy/resolve endpoint (version mismatch).","solutions":["Confirm server connectivity and that both sides support policy/resolve.","Check the SourceInfo used for policyTargetURLParameters is valid and properly encoded.","Unwrap the error for the HTTP status to distinguish 404/405 (endpoint missing) from transport errors.","Retry after transient connectivity failures."],"exampleFix":"// before\nres, err := serverapi.ResolvePolicy(ctx, cli, si, req)\nif err != nil { return err }\n// after\nres, err := serverapi.ResolvePolicy(ctx, cli, si, req)\nif err != nil {\n    return errors.Wrapf(err, \"resolving policy for %v\", si)\n}","handlingStrategy":"try-catch","validationCode":"if req == nil { return errors.New(\"nil ResolvePolicyRequest\") }\nif si.Host == \"\" { return errors.New(\"missing host in policy target\") }","typeGuard":"func isResolvePolicyErr(err error) bool { return err != nil && strings.Contains(err.Error(), \"ResolvePolicy\") }","tryCatchPattern":"resp, err := serverapi.ResolvePolicy(ctx, cli, si, req)\nif err != nil {\n    return nil, errors.Wrapf(err, \"resolve policy for %v\", si)\n}","preventionTips":["Ensure both client and server support policy/resolve.","Validate SourceInfo used for URL parameters.","Retry on transient connectivity errors.","Log the unwrapped cause to spot 404/405 endpoint-mismatch cases."],"tags":["http","api-client","policy"],"backgroundTag":"api-error-response","analyzedSha":"82495e54b584c1ef6073c9e1be048f57f8aef078","analyzedAt":"2026-09-07T20:35:21.689Z","contentChangedAt":"2026-09-07T20:35:21.689Z","schemaVersion":2},"datasetVersion":"2026-09-17T15:17:12.973Z"}