{"record":{"id":"213a98b8a8241a2a","repo":"OrchardCMS/OrchardCore","slug":"file-path-must-be-a-non-empty-string","errorCode":null,"errorMessage":"File path must be a non-empty string.","messagePattern":"File path must be a non-empty string\\.","errorType":"exception","errorClass":"ArgumentException","httpStatus":null,"severity":"error","filePath":"src/OrchardCore/OrchardCore.Abstractions/Modules/Overrides/Configuration/TenantJsonConfigurationExtensions.cs","lineNumber":73,"sourceCode":"    /// <summary>\n    /// Adds a JSON configuration source to <paramref name=\"builder\"/>.\n    /// </summary>\n    /// <param name=\"builder\">The <see cref=\"IConfigurationBuilder\"/> to add to.</param>\n    /// <param name=\"provider\">The <see cref=\"IFileProvider\"/> to use to access the file.</param>\n    /// <param name=\"path\">Path relative to the base path stored in\n    /// <see cref=\"IConfigurationBuilder.Properties\"/> of <paramref name=\"builder\"/>.</param>\n    /// <param name=\"optional\">Whether the file is optional.</param>\n    /// <param name=\"reloadOnChange\">Whether the configuration should be reloaded if the file changes.</param>\n    /// <returns>The <see cref=\"IConfigurationBuilder\"/>.</returns>\n    public static IConfigurationBuilder AddTenantJsonFile(this IConfigurationBuilder builder, IFileProvider? provider, string path, bool optional, bool reloadOnChange)\n    {\n        // ThrowHelper.ThrowIfNull(builder);\n        ArgumentNullException.ThrowIfNull(builder);\n\n        if (string.IsNullOrEmpty(path))\n        {\n            // throw new ArgumentException(SR.Error_InvalidFilePath, nameof(path));\n            throw new ArgumentException(\"File path must be a non-empty string.\", nameof(path));\n        }\n\n        return builder.AddTenantJsonFile(s =>\n        {\n            s.FileProvider = provider;\n            s.Path = path;\n            s.Optional = optional;\n            s.ReloadOnChange = reloadOnChange;\n            s.ResolveFileProvider();\n        });\n    }\n\n    /// <summary>\n    /// Adds a JSON configuration source to <paramref name=\"builder\"/>.\n    /// </summary>\n    /// <param name=\"builder\">The <see cref=\"IConfigurationBuilder\"/> to add to.</param>\n    /// <param name=\"configureSource\">Configures the source.</param>\n    /// <returns>The <see cref=\"IConfigurationBuilder\"/>.</returns>","sourceCodeStart":55,"sourceCodeEnd":91,"githubUrl":"https://github.com/OrchardCMS/OrchardCore/blob/4306c0717fe573f6fca1b4955909ddab6a192807/src/OrchardCore/OrchardCore.Abstractions/Modules/Overrides/Configuration/TenantJsonConfigurationExtensions.cs#L55-L91","documentation":"AddTenantJsonFile registers a tenant-scoped JSON configuration source for the given builder. A null/empty path cannot identify the JSON file, so the extension throws ArgumentException with paramName 'path', mirroring the framework's AddJsonFile validation.","triggerScenarios":"Calling configurationBuilder.AddTenantJsonFile(path) or AddTenantJsonFile(provider, path, optional, reloadOnChange) with path == null, path == \"\" or whitespace-only string.","commonSituations":"The tenant's appsettings file name comes from ShellSettings or a config value that is unset (e.g. a new tenant not yet configured), a renamed settings property, or passing an unvalidated variable built at runtime.","solutions":["Pass a valid non-empty file name, typically $\"appsettings.{tenantName}.json\".","Validate/guard the path at the call site before building configuration.","If the file may legitimately be absent, still pass a real name and set optional: true.","Trace where the empty path originates (ShellSettings.Configuration) and fix the tenant setup."],"exampleFix":"// before\nbuilder.AddTenantJsonFile(tenantSettings.File);\n// after\nif (!string.IsNullOrEmpty(tenantSettings.File))\n{\n    builder.AddTenantJsonFile(tenantSettings.File, optional: true);\n}","handlingStrategy":"validation","validationCode":"ArgumentException.ThrowIfNullOrWhiteSpace(path); // .NET 8+, or: if (string.IsNullOrWhiteSpace(path)) throw new ArgumentException(nameof(path));","typeGuard":"bool HasTenantFile(ShellSettings s) => !string.IsNullOrWhiteSpace(s.File);","tryCatchPattern":"try { builder.AddTenantJsonFile(path, optional: true); }\ncatch (ArgumentException ex) when (ex.ParamName == \"path\") { /* skip optional tenant config */ }","preventionTips":["Default tenant config file names at tenant creation time","Use optional:true for per-tenant files that may not exist","Guard variables derived from ShellSettings before building configuration"],"tags":["configuration","argument-validation","tenants"],"backgroundTag":"empty-required-field","analyzedSha":"4306c0717fe573f6fca1b4955909ddab6a192807","analyzedAt":"2026-09-13T17:41:05.024Z","contentChangedAt":"2026-09-13T17:41:05.024Z","schemaVersion":2},"datasetVersion":"2026-09-16T04:17:20.429Z"}