{"record":{"id":"2d78d02c7acb6a82","repo":"dotnet/wpf","slug":"compoundfile-path-must-be-non-empty","errorCode":null,"errorMessage":"CompoundFile path must be non-empty.","messagePattern":"CompoundFile path must be non-empty\\.","errorType":"exception","errorClass":"ArgumentException","httpStatus":null,"severity":"error","filePath":"src/Microsoft.DotNet.Wpf/src/WindowsBase/MS/Internal/IO/Packaging/CompoundFile/CompoundFileStreamReference.cs","lineNumber":139,"sourceCode":"        /// </summary>\n        /// <remarks>this should only be called from constructors as references are immutable</remarks>\n        /// <param name=\"fullName\">string to parse</param>\n        /// <exception cref=\"ArgumentException\">if leading or trailing path delimiter</exception>\n        private void SetFullName(string fullName)\n        {\n            ContainerUtilities.CheckStringAgainstNullAndEmpty(fullName, \"fullName\");\n\n            // fail on leading path separator to match functionality across the board\n            // Although we need to do ToUpperInvariant before we do string comparison, in this case\n            //  it is not necessary since PathSeparatorAsString is a path symbol\n            if (fullName.StartsWith(ContainerUtilities.PathSeparatorAsString, StringComparison.Ordinal))\n                throw new ArgumentException(\n                    SR.DelimiterLeading, nameof(fullName));\n\n            _fullName = fullName;\n            string[] strings = ContainerUtilities.ConvertBackSlashPathToStringArrayPath(fullName);\n            if (strings.Length == 0)\n                throw new ArgumentException(\n                    SR.CompoundFilePathNullEmpty, nameof(fullName));\n        }\n\n        //------------------------------------------------------\n        //\n        //   Private members\n        //\n        //------------------------------------------------------\n        // this can never be null - use String.Empty\n        private String _fullName;  // whack-path\n    }\n}\n","sourceCodeStart":121,"sourceCodeEnd":152,"githubUrl":"https://github.com/dotnet/wpf/blob/81131a70a4c573cd62748a5c36908fc4d662daa9/src/Microsoft.DotNet.Wpf/src/WindowsBase/MS/Internal/IO/Packaging/CompoundFile/CompoundFileStreamReference.cs#L121-L152","documentation":"CompoundFileStreamReference.SetFullName rejects names that reduce to an empty path: after ConvertBackSlashPathToStringArrayPath yields zero segments, the stream cannot be identified. It throws ArgumentException with SR.CompoundFilePathNullEmpty. A stream name must contain at least one path segment.","triggerScenarios":"new CompoundFileStreamReference(\"\") or a name consisting only of separators that produces an empty string array.","commonSituations":"Uninitialized/default string variables, empty values from config files or user forms, upstream parsing failures yielding empty names.","solutions":["Guard with String.IsNullOrEmpty and require at least one non-segment character before constructing.","Validate that the split path yields >= 1 segment before calling the API.","Fix upstream code to propagate real names or skip empty entries instead of passing them through.","Add input validation at the config/UI boundary."],"exampleFix":"// before\nvar streamRef = new CompoundFileStreamReference(name); // name may be \"\"\n// after\nif (string.IsNullOrWhiteSpace(name) || name.Split('/').All(string.IsNullOrEmpty))\n    throw new ArgumentException(\"Stream name must be a non-empty path.\", nameof(name));\nvar streamRef = new CompoundFileStreamReference(name);","handlingStrategy":"validation","validationCode":"if (string.IsNullOrWhiteSpace(name) || name.Split('/').All(string.IsNullOrEmpty)) throw new ArgumentException(\"Stream name must be a non-empty path.\");","typeGuard":"bool IsNonEmptyStreamPath(string name) => !string.IsNullOrEmpty(name) && ContainerUtilities.ConvertBackSlashPathToStringArrayPath(name).Length > 0;","tryCatchPattern":"try { new CompoundFileStreamReference(name); }\ncatch (ArgumentException) { throw new ArgumentException(\"Non-empty stream path required.\", nameof(name)); }","preventionTips":["Reject null/empty/separator-only names before API calls","Initialize name variables with valid defaults","Validate config and form inputs for emptiness"],"tags":["argument","path","empty-string","validation","packaging"],"backgroundTag":"empty-required-field","analyzedSha":"81131a70a4c573cd62748a5c36908fc4d662daa9","analyzedAt":"2026-09-14T10:12:48.479Z","contentChangedAt":"2026-09-14T10:12:48.479Z","schemaVersion":2},"datasetVersion":"2026-09-22T01:17:13.364Z"}