{"record":{"id":"63985bcf00b86bfb","repo":"vectordotdev/vector","slug":"stack-was-empty-during-pop-unevaluated","errorCode":null,"errorMessage":"stack was empty during pop","messagePattern":"stack was empty during pop","errorType":"panic","errorClass":null,"httpStatus":null,"severity":"error","filePath":"lib/vector-config/src/schema/visitors/unevaluated.rs","lineNumber":136,"sourceCode":"                unmark_or_flatten_schema(definitions, subschema);\n            }\n        }\n\n        // If we encountered any subschema validation, or if this schema itself is an object schema,\n        // mark the schema as closed by setting `unevaluatedProperties` to `false`.\n        if had_relevant_subschemas || is_object_schema(schema) {\n            mark_schema_closed(schema);\n        }\n    }\n}\n\nimpl ScopedVisitor for DisallowUnevaluatedPropertiesVisitor {\n    fn push_schema_scope<S: Into<SchemaReference>>(&mut self, scope: S) {\n        self.scope_stack.push(scope.into());\n    }\n\n    fn pop_schema_scope(&mut self) {\n        self.scope_stack.pop().expect(\"stack was empty during pop\");\n    }\n\n    fn get_current_schema_scope(&self) -> &SchemaReference {\n        self.scope_stack.current().unwrap_or(&SchemaReference::Root)\n    }\n}\n\nfn unmark_or_flatten_schema(definitions: &mut Map<String, Schema>, schema: &mut SchemaObject) {\n    // If the schema is an object schema, we'll unset `unevaluatedProperties` directly.\n    // If it isn't an object schema, we'll see if the subschema is actually a schema\n    // reference, and if so, we'll make sure to unset `unevaluatedProperties` on the\n    // resolved schema reference itself.\n    //\n    // Like the top-level schema reference logic, this ensures the schema definition is\n    // updated for subsequent resolution.\n    if let Some(object) = schema.object.as_mut() {\n        debug!(\"Unmarked object subschema directly.\");\n","sourceCodeStart":118,"sourceCodeEnd":154,"githubUrl":"https://github.com/vectordotdev/vector/blob/bdb87aeaa4c4ff27c0ba643c1c77b21bf2ef4013/lib/vector-config/src/schema/visitors/unevaluated.rs#L118-L154","documentation":"`pop_schema_scope` on `DisallowUnevaluatedPropertiesVisitor` pops its scope stack and asserts it was non-empty. The visitor maintains balanced push/pop pairs during scoped traversal; the panic fires when pop is called with nothing on the stack, indicating the traversal contract was broken.","triggerScenarios":"Calling `pop_schema_scope` without a prior `push_schema_scope` — invoking visitor methods directly instead of via the scoped traversal driver, or a schema structure causing unbalanced scope transitions.","commonSituations":"Custom traversal glue around scoped visitors; test code calling `pop_schema_scope` manually; nested `$ref` structures hitting an edge case in the driver.","solutions":["Drive the visitor only through `visit_schema_object_scoped`/standard scoped traversal","Audit any custom code that calls push/pop directly for balance","Reproduce with a minimal schema to find the unbalanced traversal point","Report upstream with the component config that reproduces it"],"exampleFix":"// before\nvisitor.pop_schema_scope(); // nothing pushed\n// after\nvisitor.push_schema_scope(\"MyDef\");\nvisitor.visit_schema_object_scoped(...);\nvisitor.pop_schema_scope();","handlingStrategy":"try-catch","validationCode":"if visitor.is_scope_stack_empty() {\n    return Err(\"pop_schema_scope called with empty scope stack\".into());\n}","typeGuard":null,"tryCatchPattern":"if let Some(scope) = visitor.scope_stack.pop_if_nonempty() {\n    // proceed\n} else {\n    tracing::error!(\"unbalanced pop_schema_scope detected\");\n}","preventionTips":["Never call pop_schema_scope manually; rely on the scoped traversal driver","Assert scope-stack balance at the end of traversal in tests","Cover nested-$ref schemas in visitor unit tests"],"tags":["rust","schema-generation","visitor-pattern"],"backgroundTag":"internal-invariant-violation","analyzedSha":"bdb87aeaa4c4ff27c0ba643c1c77b21bf2ef4013","analyzedAt":"2026-09-16T02:53:35.741Z","contentChangedAt":"2026-09-16T02:53:35.741Z","schemaVersion":2},"datasetVersion":"2026-09-23T08:17:48.524Z"}