{"record":{"id":"6ffbcf3dce7ee4f2","repo":"cli/cli","slug":"limit-must-be-greater-than-0-and-less-than-or-equa","errorCode":null,"errorMessage":"limit must be greater than 0 and less than or equal to %d","messagePattern":"limit must be greater than 0 and less than or equal to (.+?)","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"pkg/cmd/attestation/api/client.go","lineNumber":47,"sourceCode":"// Allow injecting backoff interval in tests.\nvar getAttestationRetryInterval = time.Millisecond * 200\n\n// FetchParams are the parameters for fetching attestations from the GitHub API\ntype FetchParams struct {\n\tDigest        string\n\tLimit         int\n\tOwner         string\n\tPredicateType string\n\tRepo          string\n\tInitiator     string\n}\n\nfunc (p *FetchParams) Validate() error {\n\tif p.Digest == \"\" {\n\t\treturn fmt.Errorf(\"digest must be provided\")\n\t}\n\tif p.Limit <= 0 || p.Limit > maxLimitForFlag {\n\t\treturn fmt.Errorf(\"limit must be greater than 0 and less than or equal to %d\", maxLimitForFlag)\n\t}\n\tif p.Repo == \"\" && p.Owner == \"\" {\n\t\treturn fmt.Errorf(\"owner or repo must be provided\")\n\t}\n\treturn nil\n}\n\n// githubApiClient makes REST calls to the GitHub API\ntype githubApiClient interface {\n\tREST(hostname, method, p string, body io.Reader, data interface{}) error\n\tRESTWithNext(hostname, method, p string, body io.Reader, data interface{}) (string, error)\n}\n\n// httpClient makes HTTP calls to all non-GitHub API endpoints\ntype httpClient interface {\n\tGet(url string) (*http.Response, error)\n}\n","sourceCodeStart":29,"sourceCodeEnd":65,"githubUrl":"https://github.com/cli/cli/blob/0eeec0b92edbe70199f9768522f831d3534f41ad/pkg/cmd/attestation/api/client.go#L29-L65","documentation":"FetchParams.Validate enforces 0 < Limit <= maxLimitForFlag. The GitHub attestations endpoint is paginated and the library fetches until Limit is reached; a zero/negative limit would never fetch anything and an oversized limit would page the API excessively, so both are rejected up front.","triggerScenarios":"Calling GetByDigest with FetchParams{Limit: 0} (the Go zero value, i.e. forgetting to set Limit) or Limit > maxLimitForFlag; CLI users hitting the cap with an arbitrarily large --limit.","commonSituations":"Library callers constructing FetchParams without initializing Limit because 0 is the natural default; scripts bumping --limit to 'get everything'; version changes that altered the maximum.","solutions":["Set Limit explicitly, e.g. FetchParams{Digest: d, Repo: r, Limit: 30}","Keep it within the documented maximum (maxLimitForFlag); if you truly need more, page through multiple calls","Default your own wrapper to a sane value (e.g. 30) whenever the user omits one"],"exampleFix":"// before\nparams := api.FetchParams{Digest: digest, Repo: repo}\n// after\nparams := api.FetchParams{Digest: digest, Repo: repo, Limit: 30}","handlingStrategy":"validation","validationCode":"const defaultLimit = 30\nif params.Limit == 0 { params.Limit = defaultLimit }\nif params.Limit < 1 || params.Limit > maxLimitForFlag {\n    return fmt.Errorf(\"limit must be in (0, %d]\", maxLimitForFlag)\n}","typeGuard":null,"tryCatchPattern":"if err := params.Validate(); err != nil {\n    if strings.Contains(err.Error(), \"limit must be greater than 0\") {\n        params.Limit = 30\n        err = params.Validate()\n    }\n}","preventionTips":["Never leave Limit at the Go zero value in FetchParams","Centralize a default limit in your wrapper","Respect the documented --limit maximum instead of bypassing it"],"tags":["go","supply-chain","attestations","validation"],"backgroundTag":null,"analyzedSha":"0eeec0b92edbe70199f9768522f831d3534f41ad","analyzedAt":"2026-08-15T12:31:05.478Z","schemaVersion":2},"datasetVersion":"2026-08-15T22:17:37.221Z"}