{"record":{"id":"e036ebdfab00255a","repo":"Hmbown/CodeWhale","slug":"repaired-result","errorCode":null,"errorMessage":"repaired result","messagePattern":"repaired result","errorType":"panic","errorClass":null,"httpStatus":null,"severity":"error","filePath":"crates/tui/src/client.rs","lineNumber":8421,"sourceCode":"\n        let prepared = client.prepare_model_bound_request(request);\n\n        assert!(prepared.messages.iter().any(|message| {\n            message.content.iter().any(|block| {\n                matches!(\n                    block,\n                    ContentBlock::ToolResult {\n                        tool_use_id,\n                        content,\n                        is_error: Some(true),\n                        ..\n                    } if tool_use_id == \"call-secret-test\"\n                        && content.contains(\"crashed_and_repaired\")\n                )\n            })\n        }));\n        assert_eq!(\n            prepared.messages.last().expect(\"repaired result\").role,\n            \"user\"\n        );\n        assert!(!prepared.messages.iter().any(|message| {\n            message.content.iter().any(|block| {\n                matches!(\n                    block,\n                    ContentBlock::Text { text, .. }\n                        if text.contains(\"[tool_history_repair]\")\n                )\n            })\n        }));\n    }\n\n    #[test]\n    fn model_bound_tool_results_keep_ordinary_code_byte_exact() {\n        // #5546: key-only hits in source files must reach the model unchanged\n        // so exact-match edits and read-back verification keep working.\n        let client = client_with_config_secret_sentinels();","sourceCodeStart":8403,"sourceCodeEnd":8439,"githubUrl":"https://github.com/Hmbown/CodeWhale/blob/73e0f67d83c59909b571efdfc88c4bc28c309cb1/crates/tui/src/client.rs#L8403-L8439","documentation":"A panic from `prepared.messages.last().expect(\"repaired result\")` in the dangling-tool-call repair test. The test asserts the LAST prepared message is the repaired user-role tool result; the expect fires when the prepared message list is empty — i.e. projection produced no messages at all, so the repair path emitted nothing.","triggerScenarios":"`prepared.messages.last()` returns None because the model-bound repair produced zero messages — usually after projection/repair refactors that drop the dangling tool-call's repaired user message, or when the input request's tool_use_id/content guards no longer match.","commonSituations":"Changes to the dangling tool-call repair that skip emission when the sentinel content 'crashed_and_repaired' or tool_use_id 'call-secret-test' matching changes; upstream projection filtering out user messages for the configured model.","solutions":["Dump prepared.messages (length and roles) before the assertion to see whether repair emitted anything.","Verify the repair matcher still expects tool_use_id \"call-secret-test\" and content containing \"crashed_and_repaired\" after refactors.","Check recent edits to the repair-before-adapter-projection path for early-return or filtering that drops the repaired message.","Confirm client_with_config_secret_sentinels still constructs a client whose model routes through the repairing adapter."],"exampleFix":"// before\nassert_eq!(prepared.messages.last().expect(\"repaired result\").role, \"user\");\n// after\nlet last = prepared.messages.last().unwrap_or_else(|| panic!(\"no repaired message, prepared = {prepared:#?}\"));\nassert_eq!(last.role, \"user\");","handlingStrategy":"validation","validationCode":"// rust: check the repair actually emitted a message before asserting role\nassert!(!prepared.messages.is_empty(), \"repair produced no messages\");","typeGuard":null,"tryCatchPattern":"let last = prepared.messages.last()\n    .unwrap_or_else(|| panic!(\"empty prepared.messages: {prepared:#?}\"));\nassert_eq!(last.role, \"user\");","preventionTips":["Keep repair matchers (tool_use_id, sentinel content) as shared constants used by both producer and test.","Assert on prepared message count before positional assertions like .last().","After touching the repair path, run its targeted test and inspect the prepared dump, not just pass/fail."],"tags":["rust","test-assertion","repair-logic","message-projection"],"backgroundTag":"unexpected-response-shape","analyzedSha":"73e0f67d83c59909b571efdfc88c4bc28c309cb1","analyzedAt":"2026-09-22T01:30:00.501Z","contentChangedAt":"2026-09-22T01:30:00.501Z","schemaVersion":2},"datasetVersion":"2026-09-23T08:17:48.524Z"}