{"record":{"id":"b4fd440025952070","repo":"vectordotdev/vector","slug":"argument-must-be-a-string-b4fd44","errorCode":null,"errorMessage":"argument must be a string","messagePattern":"argument must be a string","errorType":"panic","errorClass":null,"httpStatus":null,"severity":"error","filePath":"lib/vector-vrl/functions/src/remove_secret.rs","lineNumber":5,"sourceCode":"use vector_vrl_category::Category;\nuse vrl::prelude::*;\n\nfn remove_secret(ctx: &mut Context, key: Value) -> std::result::Result<Value, ExpressionError> {\n    let key_str = key.as_str().expect(\"argument must be a string\");\n    ctx.target_mut().remove_secret(key_str.as_ref());\n    Ok(Value::Null)\n}\n\n#[derive(Clone, Copy, Debug)]\npub struct RemoveSecret;\n\nimpl Function for RemoveSecret {\n    fn identifier(&self) -> &'static str {\n        \"remove_secret\"\n    }\n\n    fn usage(&self) -> &'static str {\n        \"Removes a secret from an event.\"\n    }\n\n    fn category(&self) -> &'static str {\n        Category::Event.as_ref()","sourceCodeStart":1,"sourceCodeEnd":23,"githubUrl":"https://github.com/vectordotdev/vector/blob/3708c39b12a93212ed8b8d7510b4cc7769cb5864/lib/vector-vrl/functions/src/remove_secret.rs#L1-L23","documentation":"remove_secret's runtime helper does key.as_str().expect(\"argument must be a string\") (lib/vector-vrl/functions/src/remove_secret.rs). Like the other VRL built-ins, the key parameter is declared as BYTES and enforced by the VRL compiler at compile time, so the expect defends an internal invariant: a non-string Value reaching the helper means the type-checking contract was violated, not a user config problem.","triggerScenarios":"Reaching the helper with a Value that is not bytes/string — only possible via compiler bugs, mismatched vector-vrl crate versions in a custom build, or embedding code invoking the function outside the normal compile+run pipeline. Hand-written remove_secret(true) fails compilation with a type error long before this panic.","commonSituations":"Custom embeddings of VRL; version-mismatched crates after a partial dependency upgrade; nightly/regression builds of the VRL compiler losing a parameter kind.","solutions":["Upgrade vector / vector-vrl crates together so the compiler's parameter kinds match the function implementation","Pass compile-time-checked string arguments (literals or to_string!-coerced values) in VRL programs","If embedding VRL directly, invoke functions only through the compiled program handle, never the raw helpers","Report a reproducer to vectordot/vector if a stock build panics here"],"exampleFix":"# before (vrl)\nremove_secret(secret_key)  # secret_key: any\n\n# after (vrl)\nremove_secret(to_string!(secret_key))","handlingStrategy":"type-guard","validationCode":"# Ensure a bytes key at the call site\nremove_secret(to_string!(key))","typeGuard":"fn is_bytes(v: &vrl::value::Value) -> bool {\n    matches!(v, vrl::value::Value::Bytes(_))\n}","tryCatchPattern":null,"preventionTips":["Compile-check programs (vector vrl check / vector validate) before deploying","Embed VRL only via the compiled Program API","Upgrade vector-vrl crates in lockstep"],"tags":["vector","vrl","type-invariant","secrets","panic","internal"],"backgroundTag":"type-invariant-violation","analyzedSha":"3708c39b12a93212ed8b8d7510b4cc7769cb5864","analyzedAt":"2026-08-20T07:02:18.786Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-14T05:17:10.506Z"}