{"record":{"id":"7a5be0428405a5ca","repo":"alibaba/nacos","slug":"400-7a5be0","errorCode":"400","errorMessage":"could not determine a constructor for the tag {}{}","messagePattern":"could not determine a constructor for the tag (.+?)(.+?)","errorType":"validation","errorClass":"NacosRuntimeException","httpStatus":null,"severity":"error","filePath":"config/src/main/java/com/alibaba/nacos/config/server/utils/YamlParserUtil.java","lineNumber":107,"sourceCode":"        protected NodeTuple representJavaBeanProperty(Object javaBean, Property property,\n            Object propertyValue,\n            Tag customTag) {\n            if (propertyValue == null) {\n                return null;\n            } else {\n                return super.representJavaBeanProperty(javaBean, property, propertyValue,\n                    customTag);\n            }\n        }\n    }\n    \n    public static class ConstructYamlConfigMetadata extends AbstractConstruct {\n        \n        @Override\n        public Object construct(Node node) {\n            if (!YamlParserConstructor.CONFIG_METADATA_TAG.getValue()\n                .equals(node.getTag().getValue())) {\n                throw new NacosRuntimeException(NacosException.INVALID_PARAM,\n                    \"could not determine a constructor for the tag \" + node.getTag()\n                        + node.getStartMark());\n            }\n            \n            MappingNode mNode = (MappingNode) node;\n            List<NodeTuple> value = mNode.getValue();\n            if (CollectionUtils.isEmpty(value)) {\n                return null;\n            }\n            NodeTuple nodeTuple = value.get(0);\n            ConfigMetadata configMetadata = new ConfigMetadata();\n            SequenceNode sequenceNode = (SequenceNode) nodeTuple.getValueNode();\n            if (CollectionUtils.isEmpty(sequenceNode.getValue())) {\n                return configMetadata;\n            }\n            \n            List<ConfigMetadata.ConfigExportItem> exportItems =\n                sequenceNode.getValue().stream().map(itemValue -> {","sourceCodeStart":89,"sourceCodeEnd":125,"githubUrl":"https://github.com/alibaba/nacos/blob/9b989acdf181d00898f2e8839257bb2b2a3cefe3/config/src/main/java/com/alibaba/nacos/config/server/utils/YamlParserUtil.java#L89-L125","documentation":"Thrown by YamlParserUtil.ConstructYamlConfigMetadata.construct as a NacosRuntimeException with code NacosException.INVALID_PARAM (400) when a YAML node's tag does not equal the expected CONFIG_METADATA_TAG (the tag bound to com.alibaba.nacos.config.server.model.ConfigMetadata). The parser only knows how to construct nodes tagged as ConfigMetadata; any other root tag is rejected. The message appends the actual tag and its start mark for locating the offending YAML position.","triggerScenarios":"Calling YamlParserUtil.loadObject(content, ConfigMetadata.class) on a YAML document whose root tag is not the ConfigMetadata tag - e.g. a hand-edited metadata YAML missing the custom tag, a generic YAML map, or a metadata file produced by a different/older Nacos version with a different tag scheme. Also reachable via config export/import metadata parsing.","commonSituations":"Re-importing a config-metadata YAML that was edited externally (tag stripped/renamed), loading a plain YAML as ConfigMetadata, version mismatch between the exporter and importer, or a truncated/corrupted metadata file.","solutions":["Regenerate the metadata YAML via YamlParserUtil.dumpObject(new ConfigMetadata()) so it carries the correct tag, instead of hand-editing it.","If editing is unavoidable, ensure the root node carries the ConfigMetadata tag expected by the running Nacos version.","Validate that the file is a Nacos config-metadata export for this server version before importing."],"exampleFix":"// before (hand-written / generic yaml loaded as ConfigMetadata)\nConfigMetadata md = YamlParserUtil.loadObject(rawYaml, ConfigMetadata.class); // tag mismatch\n\n// after (round-trip through the serializer to guarantee the tag)\nString safe = YamlParserUtil.dumpObject(originalMetadata);\nConfigMetadata md = YamlParserUtil.loadObject(safe, ConfigMetadata.class);","handlingStrategy":"validation","validationCode":"// Ensure the YAML carries the ConfigMetadata tag before parsing.\n// Prefer round-tripping through the serializer rather than hand-editing:\nString safe = YamlParserUtil.dumpObject(new ConfigMetadata());\nString expectedTag = \"!<\" + ConfigMetadata.class.getName() + \">\"; // tag scheme for this version\nboolean looksValid = rawYaml != null && rawYaml.contains(ConfigMetadata.class.getName());","typeGuard":null,"tryCatchPattern":"try {\n    ConfigMetadata md = YamlParserUtil.loadObject(content, ConfigMetadata.class);\n} catch (NacosRuntimeException e) {\n    if (e.getCode() == NacosException.INVALID_PARAM) {\n        // metadata YAML tag mismatch - regenerate from a known-good export\n        throw new IllegalArgumentException(\"Invalid config metadata YAML: \" + e.getMessage());\n    } else throw e;\n}","preventionTips":["Never hand-edit config-metadata YAML; regenerate it via YamlParserUtil.dumpObject.","Import metadata only from exports produced by the same Nacos version.","Treat a tag-mismatch error as a corrupted/incompatible metadata file, not a transient failure."],"tags":["config","yaml","serialization","metadata","import-export","invalid-param"],"backgroundTag":null,"analyzedSha":"9b989acdf181d00898f2e8839257bb2b2a3cefe3","analyzedAt":"2026-08-14T07:17:31.569Z","schemaVersion":2},"datasetVersion":"2026-08-14T10:17:34.591Z"}