{"record":{"id":"36702f39d75aa0d6","repo":"Unity-Technologies/UnityCsReference","slug":"config-object-with-name-name-already-exists","errorCode":null,"errorMessage":"Config object with name '${name}' already exists.","messagePattern":"Config object with name '(.+?)' already exists\\.","errorType":"exception","errorClass":"Exception","httpStatus":null,"severity":"error","filePath":"Editor/Mono/EditorBuildSettings.bindings.cs","lineNumber":174,"sourceCode":"        }\n\n        [Obsolete(\"UseParallelAssetBundleBuilding is obsolete and will be removed.\")]\n        [NoAutoStaticsCleanup] // deprecated value-type setting; safe to persist across reload\n        public static bool UseParallelAssetBundleBuilding { get; set; } = false;\n\n        [NativeMethod(\"AddConfigObject\")]\n        static extern ConfigObjectResult AddConfigObjectInternal(string name, Object obj, bool overwrite);\n        public static extern bool RemoveConfigObject(string name);\n        public static extern string[] GetConfigObjectNames();\n        static extern Object GetConfigObject(string name);\n        public static void AddConfigObject(string name, Object obj, bool overwrite)\n        {\n            var result = AddConfigObjectInternal(name, obj, overwrite);\n            if (result == ConfigObjectResult.Succeeded)\n                return;\n            switch (result)\n            {\n                case ConfigObjectResult.FailedEntryExists: throw new Exception(\"Config object with name '\" + name + \"' already exists.\");\n                case ConfigObjectResult.FailedNonPersistedObj: throw new Exception(\"Cannot add non-persisted config object with name '\" + name + \"'.\");\n                case ConfigObjectResult.FailedNullObj: throw new Exception(\"Cannot add null config object with name '\" + name + \"'.\");\n            }\n        }\n\n        public static bool TryGetConfigObject<T>(string name, out T result) where T : Object\n        {\n            result = GetConfigObject(name) as T;\n            return result != null;\n        }\n    }\n}\n","sourceCodeStart":156,"sourceCodeEnd":187,"githubUrl":"https://github.com/Unity-Technologies/UnityCsReference/blob/225b0fbdb57cc17d094e8056b71f8314aba56f73/Editor/Mono/EditorBuildSettings.bindings.cs#L156-L187","documentation":"Thrown by EditorBuildSettings.AddConfigObject when the native AddConfigObjectInternal returns ConfigObjectResult.FailedEntryExists — a config object with the given name is already stored and overwrite was false. Config objects are arbitrary key→UnityEngine.Object associations persisted in EditorBuildSettings (per-build-target editor config). The native side returns a result enum rather than overwriting silently.","triggerScenarios":"Calling EditorBuildSettings.AddConfigObject(name, obj, overwrite:false) when GetConfigObjectNames() already contains 'name'. Re-running a setup script without first removing the entry or without overwrite:true.","commonSituations":"Build pipeline initialization scripts that register config objects and are re-run (iteration, CI without a clean state); two packages/scripts using the same config key.","solutions":["Pass overwrite:true when you intend to replace an existing entry.","Remove first: if (EditorBuildSettings.GetConfigObjectNames().Contains(name)) EditorBuildSettings.RemoveConfigObject(name);","Use a unique, namespaced key per script/package to avoid collisions."],"exampleFix":"// before\nEditorBuildSettings.AddConfigObject(\"MyConfig\", asset, overwrite: false);\n// after\nEditorBuildSettings.AddConfigObject(\"com.mycompany.MyConfig\", asset, overwrite: true);","handlingStrategy":"validation","validationCode":"if (Array.IndexOf(EditorBuildSettings.GetConfigObjectNames(), name) >= 0)\n    EditorBuildSettings.RemoveConfigObject(name);\nEditorBuildSettings.AddConfigObject(name, obj, overwrite: true);","typeGuard":null,"tryCatchPattern":"try { EditorBuildSettings.AddConfigObject(name, obj, overwrite: false); }\ncatch (Exception ex) when (ex.Message.Contains(\"already exists\"))\n{ /* entry present; remove or pass overwrite:true */ }","preventionTips":["Use overwrite:true when re-running setup scripts.","Namespaces your config keys (com.package.name) to avoid collisions.","Make setup idempotent: remove-then-add or check-then-add."],"tags":["editor","build-settings","config","duplicate","persistence"],"backgroundTag":null,"analyzedSha":"225b0fbdb57cc17d094e8056b71f8314aba56f73","analyzedAt":"2026-08-13T19:07:19.849Z","schemaVersion":2},"datasetVersion":"2026-08-13T19:17:28.613Z"}