{"record":{"id":"d00a34a2a78d7bb1","repo":"OpenFeign/feign","slug":"received-excessive-request-s","errorCode":null,"errorMessage":"Received excessive request %s","messagePattern":"Received excessive request (.+?)","errorType":"exception","errorClass":"VerificationAssertionError","httpStatus":null,"severity":"error","filePath":"mock/src/main/java/feign/mock/MockClient.java","lineNumber":92,"sourceCode":"    RequestKey requestKey = RequestKey.create(request);\n    Response.Builder responseBuilder;\n    if (sequential) {\n      responseBuilder = executeSequential(requestKey);\n    } else {\n      responseBuilder = executeAny(request, requestKey);\n    }\n    responseBuilder.protocolVersion(ProtocolVersion.MOCK);\n\n    return CompletableFuture.completedFuture(responseBuilder.request(request).build());\n  }\n\n  private Response.Builder executeSequential(RequestKey requestKey) {\n    Response.Builder responseBuilder;\n    if (responseIterator == null) {\n      responseIterator = responses.iterator();\n    }\n    if (!responseIterator.hasNext()) {\n      throw new VerificationAssertionError(\"Received excessive request %s\", requestKey);\n    }\n\n    RequestResponse expectedRequestResponse = responseIterator.next();\n    if (!expectedRequestResponse.requestKey.equalsExtended(requestKey)) {\n      throw new VerificationAssertionError(\n          \"Expected: \\n%s,\\nbut was: \\n%s\", expectedRequestResponse.requestKey, requestKey);\n    }\n\n    responseBuilder = expectedRequestResponse.responseBuilder;\n    return responseBuilder;\n  }\n\n  private Response.Builder executeAny(Request request, RequestKey requestKey) {\n    Response.Builder responseBuilder;\n    if (requests.containsKey(requestKey)) {\n      requests.get(requestKey).add(request);\n    } else {\n      requests.put(requestKey, new ArrayList<>(Arrays.asList(request)));","sourceCodeStart":74,"sourceCodeEnd":110,"githubUrl":"https://github.com/OpenFeign/feign/blob/e2a1e27560a1e68840c34f031afca88b36096e30/mock/src/main/java/feign/mock/MockClient.java#L74-L110","documentation":"MockClient in sequential mode throws VerificationAssertionError(\"Received excessive request %s\") when more requests arrive than were queued: the response iterator is exhausted but the client under test issues another call. It means the mock was set up with fewer stubbed responses than actual invocations.","triggerScenarios":"Using MockClient with sequential behavior (e.g. mockClient.add(response) once) while the code under test calls the Feign method twice, or retries issuing extra HTTP calls.","commonSituations":"Adding retries (e.g. Retryer.NEVER_RETRY not set) causing duplicate calls; loops making more calls than stubbed; forgetting to add a response for each expected call in a sequence.","solutions":["Add a stubbed response for every expected call via mockClient.add(...) in order","Ensure the test code makes exactly as many calls as stubbed","Disable unexpected retries with Retryer.NEVER_RETRY in the Feign builder","Call mockClient.verifyStatus()/verifyResults() in tests to catch mismatches early"],"exampleFix":"// before\nmockClient.add(okResponse);\napi.call(); api.call(); // excessive request\n// after\nmockClient.add(okResponse);\nmockClient.add(secondResponse);\napi.call(); api.call();","handlingStrategy":"validation","validationCode":"// assert stub count matches expected call count before running the test\n// assertEquals(expectedCalls, mockClient.getResponsesCount()); // or count added stubs in setup","typeGuard":null,"tryCatchPattern":"try { runScenario(); }\ncatch (VerificationAssertionError e) {\n  if (e.getMessage().startsWith(\"Received excessive request\")) throw new AssertionError(\"Add a stub for every call or disable retries: \" + e.getMessage(), e);\n  throw e;\n}","preventionTips":["Stub one response per expected HTTP call, in order","Set Retryer.NEVER_RETRY in tests to prevent surprise extra calls","Run mockClient.verifyStatus()/verifyResults() to validate interaction counts"],"tags":["mock","testing","verification","feign"],"backgroundTag":"unexpected-api-response-shape","analyzedSha":"e2a1e27560a1e68840c34f031afca88b36096e30","analyzedAt":"2026-09-10T12:37:37.238Z","contentChangedAt":"2026-09-10T12:37:37.238Z","schemaVersion":2},"datasetVersion":"2026-09-16T09:17:16.951Z"}