{"record":{"id":"1dcb5c2de0864f91","repo":"dbt-labs/dbt-core","slug":"pop-key-not-found","errorCode":null,"errorMessage":"pop(): key not found","messagePattern":"pop\\(\\): key not found","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"crates/dbt-agate/src/lib.rs","lineNumber":597,"sourceCode":"\n            // --- mutating methods implemented via excluded ---\n            \"pop\" => {\n                // pop(key, default=())\n                // If key exists: create new inner with excluded index and return value.\n                // If missing: return default if provided, else error.\n                let iter = ArgsIter::new(\"OrderedDict.pop\", &[\"key\"], args);\n                let key = iter.next_arg::<&Value>()?;\n                let default = iter.next_kwarg::<Option<&Value>>(\"default\")?;\n                iter.finish()?;\n\n                let mut inner = self.inner.lock().expect(\"lock poisoned\");\n                if let Some((value, new)) = inner.pop(key) {\n                    *inner = new;\n                    Ok(value)\n                } else if let Some(default) = default {\n                    Ok(default.clone())\n                } else {\n                    Err(minijinja::Error::new(\n                        ErrorKind::NonKey,\n                        \"pop(): key not found\",\n                    ))\n                }\n            }\n\n            _ => Err(minijinja::Error::new(\n                ErrorKind::UnknownMethod,\n                format!(\"OrderedDict has no method named {name}\"),\n            )),\n        }\n    }\n}\n\n/// A generic container for immutable data that can be accessed either by\n/// numeric index or by key. This is similar to a Python `OrderedDict` except\n/// that the keys are optional and iteration over it returns the values instead\n/// of keys.","sourceCodeStart":579,"sourceCodeEnd":615,"githubUrl":"https://github.com/dbt-labs/dbt-core/blob/0267ce9170576975b76b64ce856b2e5848e96617/crates/dbt-agate/src/lib.rs#L579-L615","documentation":"Raised by OrderedDict.pop in the Jinja object emulation: the requested key is absent from the mapping and no `default` keyword was supplied, so there is nothing to return. Mirrors Python's KeyError from dict.pop without a default.","triggerScenarios":"Thrown at crates/dbt-agate/src/lib.rs:597 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":["Pass a default: my_dict.pop('missing_key', default_value)","Check key membership with 'key in my_dict' before popping","Verify the key was actually set earlier in the template"],"exampleFix":null,"handlingStrategy":"fallback","validationCode":null,"typeGuard":null,"tryCatchPattern":null,"preventionTips":[],"tags":[],"backgroundTag":null,"analyzedSha":"0267ce9170576975b76b64ce856b2e5848e96617","analyzedAt":"2026-09-07T21:53:39.732Z","contentChangedAt":"2026-09-07T21:53:39.732Z","schemaVersion":2},"datasetVersion":"2026-09-17T15:17:12.973Z"}