Unity-Technologies/UnityCsReference · error · ArgumentNullException

outNotEditablePaths

Error message

outNotEditablePaths

What it means

Thrown by AssetDatabase.CanOpenForEdit when the outNotEditablePaths List<string> is null. The method writes the subset of paths that are NOT editable into this caller-owned list; a null list cannot be appended to, so the guard throws ArgumentNullException(nameof(outNotEditablePaths)) right after the assetOrMetaFilePaths check.

Source

Thrown at Editor/Mono/AssetDatabase/AssetDatabase.cs:110

        [RequiredByNativeCode]
        private static void Internal_CallImportPackageFailed(string packageName, string errorMessage)
        {
            foreach (var evt in m_importPackageFailedEvent)
                evt(packageName, errorMessage);
        }

        [RequiredByNativeCode]
        private static bool Internal_IsOpenForEdit(string assetOrMetaFilePath)
        {
            return IsOpenForEdit(assetOrMetaFilePath);
        }

        public static void CanOpenForEdit(string[] assetOrMetaFilePaths, List<string> outNotEditablePaths, [uei.DefaultValue("StatusQueryOptions.UseCachedIfPossible")] StatusQueryOptions statusQueryOptions = StatusQueryOptions.UseCachedIfPossible)
        {
            if (assetOrMetaFilePaths == null)
                throw new ArgumentNullException(nameof(assetOrMetaFilePaths));
            if (outNotEditablePaths == null)
                throw new ArgumentNullException(nameof(outNotEditablePaths));
            UnityEngine.Profiling.Profiler.BeginSample("AssetDatabase.CanOpenForEdit");
            AssetModificationProcessorInternal.CanOpenForEdit(assetOrMetaFilePaths, outNotEditablePaths, statusQueryOptions);
            UnityEngine.Profiling.Profiler.EndSample();
        }

        public static void IsOpenForEdit(string[] assetOrMetaFilePaths, List<string> outNotEditablePaths, [uei.DefaultValue("StatusQueryOptions.UseCachedIfPossible")] StatusQueryOptions statusQueryOptions = StatusQueryOptions.UseCachedIfPossible)
        {
            if (assetOrMetaFilePaths == null)
                throw new ArgumentNullException(nameof(assetOrMetaFilePaths));
            if (outNotEditablePaths == null)
                throw new ArgumentNullException(nameof(outNotEditablePaths));
            UnityEngine.Profiling.Profiler.BeginSample("AssetDatabase.IsOpenForEdit");
            AssetModificationProcessorInternal.IsOpenForEdit(assetOrMetaFilePaths, outNotEditablePaths, statusQueryOptions);
            UnityEngine.Profiling.Profiler.EndSample();
        }

        [RequiredByNativeCode]
        private static bool Internal_MakeEditable(string path)

View on GitHub (pinned to 225b0fbdb5)

Solutions

  1. Allocate the output list before calling: new List<string>().
  2. If reusing, Clear() instead of setting to null.
  3. Pool the list across calls but ensure it is non-null at the call site.
  4. Validate the list and log a context message when null.

Example fix

// before
var notEditable = hasFlag ? new List<string>() : null;
AssetDatabase.CanOpenForEdit(paths, notEditable);

// after
var notEditable = new List<string>();
AssetDatabase.CanOpenForEdit(paths, notEditable);
Defensive patterns

Strategy: validation

Validate before calling

outNotEditablePaths ??= new List<string>(); outNotEditablePaths.Clear();

Prevention

When it happens

Trigger: Calling CanOpenForEdit(paths, null). Forgetting to allocate the output list. Reusing a field that was set to null between calls.

Common situations: Editor VCS tooling that conditionally allocates the output list. Context-menu handlers that declare the list lazily but call before allocating. Batch checks that null the list to 'reset' instead of Clear().

Related errors


AI-assisted analysis of Unity-Technologies/UnityCsReference@225b0fbdb5 (2026-08-13). Data as JSON: /api/errors/d5fd5f5bf453eb15. Report an issue: GitHub.