{"id":"8686993c2057a7e4","repo":"docker/cli","slug":"read-exceeds-the-defined-limit","errorCode":null,"errorMessage":"read exceeds the defined limit","messagePattern":"read exceeds the defined limit","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"cli/context/store/io_utils.go","lineNumber":17,"sourceCode":"package store\n\nimport (\n\t\"errors\"\n\t\"io\"\n)\n\n// limitedReader is a fork of [io.LimitedReader] to override Read.\ntype limitedReader struct {\n\tR io.Reader\n\tN int64 // max bytes remaining\n}\n\n// Read is a fork of [io.LimitedReader.Read] that returns an error when limit exceeded.\nfunc (l *limitedReader) Read(p []byte) (n int, err error) {\n\tif l.N < 0 {\n\t\treturn 0, errors.New(\"read exceeds the defined limit\")\n\t}\n\tif l.N == 0 {\n\t\treturn 0, io.EOF\n\t}\n\t// have to cap N + 1 otherwise we won't hit limit err\n\tif int64(len(p)) > l.N+1 {\n\t\tp = p[0 : l.N+1]\n\t}\n\tn, err = l.R.Read(p)\n\tl.N -= int64(n)\n\treturn n, err\n}\n","sourceCodeStart":1,"sourceCodeEnd":30,"githubUrl":"https://github.com/docker/cli/blob/e9452d6e785f6e365712b9d71bd7517591773c86/cli/context/store/io_utils.go#L1-L30","documentation":"Error \"read exceeds the defined limit\" thrown in docker/cli.","triggerScenarios":"Thrown at cli/context/store/io_utils.go:17 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":[],"exampleFix":null,"handlingStrategy":null,"validationCode":null,"typeGuard":null,"tryCatchPattern":null,"preventionTips":[],"tags":[],"analyzedSha":"e9452d6e785f6e365712b9d71bd7517591773c86","analyzedAt":"2026-08-01T07:09:22.474Z","schemaVersion":2}