{"record":{"id":"70c526025c9e3a86","repo":"aaif-goose/goose","slug":"no-valid-messages-to-send-to-snowflake-api","errorCode":null,"errorMessage":"No valid messages to send to Snowflake API","messagePattern":"No valid messages to send to Snowflake API","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"info","filePath":"crates/goose-provider-types/src/formats/snowflake.rs","lineNumber":336,"sourceCode":"    }\n}\n\n/// Create a complete request payload for Snowflake's API\npub fn create_request(\n    model_config: &ModelConfig,\n    system: &str,\n    messages: &[Message],\n    tools: &[Tool],\n) -> Result<Value> {\n    let mut snowflake_messages = format_messages(messages);\n    let system_spec = format_system(system);\n\n    // Add system message to the beginning of the messages\n    snowflake_messages.insert(0, system_spec);\n\n    // Check if we have any messages to send\n    if snowflake_messages.is_empty() {\n        return Err(anyhow!(\"No valid messages to send to Snowflake API\"));\n    }\n\n    // Detect description generation requests and exclude tools to prevent interference\n    // with normal tool execution flow\n    let is_description_request =\n        system.contains(\"Reply with only a description in four words or less\");\n\n    let tool_specs = if is_description_request {\n        // For description generation, don't include any tools to avoid confusion\n        format_tools(&[])\n    } else {\n        format_tools(tools)\n    };\n\n    let mut payload = json!({\n        \"model\": model_config.model_name,\n        \"messages\": snowflake_messages,\n        \"max_tokens\": model_config.max_output_tokens(),","sourceCodeStart":318,"sourceCodeEnd":354,"githubUrl":"https://github.com/aaif-goose/goose/blob/3810898a7447ec3299be72e223d3570a7aabf0ab/crates/goose-provider-types/src/formats/snowflake.rs#L318-L354","documentation":"create_request builds the Snowflake Cortex request payload: it formats the conversation, then unconditionally inserts the system message at index 0, and only afterwards checks snowflake_messages.is_empty(). Because the system message is always inserted first, the vector always has at least one element and this error is unreachable in the current code — it is dead guarding left over from a version that checked emptiness before the insert.","triggerScenarios":"Cannot fire with the code as shipped: format_messages output plus one inserted system message is never empty. You would only see it in a modified/reordered variant of create_request, or if a future refactor removes the unconditional insert.","commonSituations":"Hitting this in a fork where the insert(0, system_spec) line was removed or made conditional; static-analysis/audit work flagging the dead branch; tests asserting the old guard behavior.","solutions":["If you see this error, you are running modified code — check the local diff of snowflake.rs create_request","If the intent is to require user content, move the emptiness check before the system insert (see exampleFix)","Otherwise delete the dead check to avoid confusion"],"exampleFix":"// before\nsnowflake_messages.insert(0, system_spec);\nif snowflake_messages.is_empty() {\n    return Err(anyhow!(\"No valid messages to send to Snowflake API\"));\n}\n\n// after - guard checks the real conversation, not the list we just grew\nif snowflake_messages.is_empty() {\n    return Err(anyhow!(\"No valid messages to send to Snowflake API\"));\n}\nsnowflake_messages.insert(0, system_spec);","handlingStrategy":"validation","validationCode":"// the shipped guard is unreachable; validate inputs yourself before create_request\nif messages.is_empty() {\n    anyhow::bail!(\"conversation has no messages to send\");\n}\nlet payload = create_request(&model_config, system, messages, tools)?;","typeGuard":"fn has_sendable_messages(messages: &[Message]) -> bool {\n    !messages.is_empty()\n}","tryCatchPattern":null,"preventionTips":["Do not rely on this message as an empty-conversation signal — the shipped check cannot fire","Validate message lists in calling code before building requests","If maintaining a fork, move the emptiness check above the system insert"],"tags":["rust","snowflake","dead-code","request-building"],"backgroundTag":null,"analyzedSha":"3810898a7447ec3299be72e223d3570a7aabf0ab","analyzedAt":"2026-08-16T10:14:26.282Z","schemaVersion":2},"datasetVersion":"2026-08-16T13:17:31.715Z"}