{"record":{"id":"5a777e5978cb4c45","repo":"Hmbown/CodeWhale","slug":"should-error-on-empty-queue","errorCode":null,"errorMessage":"should error on empty queue","messagePattern":"should error on empty queue","errorType":"panic","errorClass":null,"httpStatus":null,"severity":"error","filePath":"crates/tui/src/llm_client/mock.rs","lineNumber":539,"sourceCode":"                    break;\n                }\n                _ => {}\n            }\n        }\n\n        assert_eq!(text, \"hello world\");\n        assert!(saw_stop);\n        assert_eq!(mock.call_count(), 1);\n        assert_eq!(mock.captured_requests().len(), 1);\n        assert_eq!(mock.remaining_turns(), 0);\n    }\n\n    #[tokio::test]\n    async fn errors_when_queue_exhausted() {\n        let mock = MockLlmClient::new(Vec::new());\n        let result = mock.create_message_stream(empty_request()).await;\n        match result {\n            Ok(_) => panic!(\"should error on empty queue\"),\n            Err(err) => assert!(format!(\"{err}\").contains(\"no canned\")),\n        }\n    }\n\n    #[tokio::test]\n    async fn captures_request_payload_for_assertions() {\n        let mock = MockLlmClient::new(vec![canned::simple_text_turn(\"ok\")]);\n        let mut req = empty_request();\n        req.temperature = Some(0.42);\n        let _ = mock.create_message_stream(req).await.unwrap();\n\n        let captured = mock.last_request().expect(\"should have captured\");\n        assert_eq!(captured.temperature, Some(0.42));\n    }\n\n    #[tokio::test]\n    async fn stream_auto_appends_message_stop() {\n        // Queue a turn missing MessageStop — mock should append one.","sourceCodeStart":521,"sourceCodeEnd":557,"githubUrl":"https://github.com/Hmbown/CodeWhale/blob/433685b2024e7bc4c99e1e2e326bcad39b4d9d65/crates/tui/src/llm_client/mock.rs#L521-L557","documentation":"Panic in the MockLlmClient test errors_when_queue_exhausted. MockLlmClient::new(Vec::new()) is created with no canned responses, so create_message_stream must return Err (containing \"no canned\"). The panic fires if the mock unexpectedly returned Ok despite an empty queue — meaning the exhausted-queue error path regressed.","triggerScenarios":"Creating MockLlmClient with an empty response queue and calling create_message_stream; the mock returns Ok(_) instead of an error mentioning \"no canned\".","commonSituations":"Refactoring the mock to synthesize streaming turns from requests changed behavior so it no longer errors on an empty queue; someone added a default canned response.","solutions":["Check MockLlmClient::create_message_stream still returns the \"no canned\" error when the queue is empty.","Ensure the new synthesis path (create_message_synthesizes_from_streaming_turn) is not applied inside create_message_stream, or split the tests.","If empty-queue Ok is now intended, rewrite the test for the new contract."],"exampleFix":"// before\nOk(_) => panic!(\"should error on empty queue\"),\n// after\nOk(resp) => panic!(\"should error on empty queue, got response with {} blocks\", resp.content.len()),","handlingStrategy":"try-catch","validationCode":"// caller-side: never construct MockLlmClient with an empty queue unless you expect the error\nassert!(!responses.is_empty(), \"mock created with empty queue; create_message_stream will fail\");","typeGuard":"fn is_no_canned(err: &LlmError) -> bool { format!(\"{err}\").contains(\"no canned\") }","tryCatchPattern":"match mock.create_message_stream(req).await { Ok(_) => panic!(\"should error on empty queue\"), Err(e) => assert!(format!(\"{e}\").contains(\"no canned\")) }","preventionTips":["Seed the mock with at least one canned response in non-error tests","Keep the exhausted-queue error message stable so tests can match it"],"tags":["rust","test-assertion","mock","async"],"backgroundTag":"empty-result-set","analyzedSha":"433685b2024e7bc4c99e1e2e326bcad39b4d9d65","analyzedAt":"2026-09-15T12:24:24.634Z","contentChangedAt":"2026-09-15T12:24:24.634Z","schemaVersion":2},"datasetVersion":"2026-09-22T06:17:15.046Z"}