{"record":{"id":"839b7a959a0efa90","repo":"microsoft/aspire","slug":"an-absolute-path-is-required-basepath","errorCode":null,"errorMessage":"An absolute path is required: '${basePath}'","messagePattern":"An absolute path is required: '(.+?)'","errorType":"validation","errorClass":"ArgumentException","httpStatus":null,"severity":"error","filePath":"src/Aspire.Hosting/ApplicationModel/AspireStore.cs","lineNumber":31,"sourceCode":"    internal const string AspireStorePathKeyName = \"Aspire:Store:Path\";\n\n    private readonly string _basePath;\n    private readonly IFileSystemService _directoryService;\n\n    /// <summary>\n    /// Initializes a new instance of the <see cref=\"AspireStore\"/> class with the specified base path.\n    /// </summary>\n    /// <param name=\"basePath\">The base path for the store.</param>\n    /// <param name=\"directoryService\">The directory service for creating temp directories.</param>\n    /// <returns>A new instance of <see cref=\"AspireStore\"/>.</returns>\n    public AspireStore(string basePath, IFileSystemService directoryService)\n    {\n        ArgumentNullException.ThrowIfNull(basePath);\n        ArgumentNullException.ThrowIfNull(directoryService);\n\n        if (!Path.IsPathRooted(basePath))\n        {\n            throw new ArgumentException($\"An absolute path is required: '${basePath}'\", nameof(basePath));\n        }\n\n        _basePath = basePath;\n        _directoryService = directoryService;\n        EnsureDirectory();\n    }\n\n    public string BasePath => _basePath;\n\n    public string GetFileNameWithContent(string filenameTemplate, Stream contentStream)\n    {\n        ArgumentException.ThrowIfNullOrWhiteSpace(filenameTemplate);\n        ArgumentNullException.ThrowIfNull(contentStream);\n\n        EnsureDirectory();\n\n        // Strip any folder information from the filename.\n        filenameTemplate = Path.GetFileName(filenameTemplate);","sourceCodeStart":13,"sourceCodeEnd":49,"githubUrl":"https://github.com/microsoft/aspire/blob/25830f84bd145686607ad00c057b3f84e2e51d43/src/Aspire.Hosting/ApplicationModel/AspireStore.cs#L13-L49","documentation":"The AspireStore constructor requires basePath to be an absolute (rooted) filesystem path. Relative paths are rejected with ArgumentException because the store must be able to unambiguously locate and create its directory regardless of the current working directory.","triggerScenarios":"Constructing AspireStore (directly or via distributed application builder store APIs) with a relative path such as \".aspire\" or \"store\" instead of a fully rooted path.","commonSituations":"Passing a user-supplied config directory without calling Path.GetFullPath; paths built from environment variables that may be relative; running from a different working directory than assumed.","solutions":["Pass an absolute path, e.g. Path.GetFullPath(yourPath) or AppContext.BaseDirectory-combined path","Use Environment.GetFolderPath / AppContext.BaseDirectory to anchor the store location before construction","If accepting user input, validate with Path.IsPathRooted before calling the constructor"],"exampleFix":"// before\nvar store = new AspireStore(\".aspire\", directoryService);\n// after\nvar store = new AspireStore(Path.GetFullPath(\".aspire\"), directoryService);","handlingStrategy":"validation","validationCode":"if (!Path.IsPathRooted(basePath)) basePath = Path.GetFullPath(basePath);","typeGuard":"bool IsAbsolute(string? p) => !string.IsNullOrWhiteSpace(p) && Path.IsPathRooted(p);","tryCatchPattern":"try { var store = new AspireStore(basePath, svc); } catch (ArgumentException ex) when (ex.ParamName == \"basePath\") { basePath = Path.GetFullPath(basePath); /* retry */ }","preventionTips":["Always anchor relative config paths with Path.GetFullPath or AppContext.BaseDirectory","Validate user-supplied paths with Path.IsPathRooted before use"],"tags":["path","configuration","aspire-store"],"backgroundTag":"invalid-argument-value","analyzedSha":"25830f84bd145686607ad00c057b3f84e2e51d43","analyzedAt":"2026-09-16T11:10:06.193Z","contentChangedAt":"2026-09-16T11:10:06.193Z","schemaVersion":2},"datasetVersion":"2026-09-21T04:17:39.646Z"}