microsoft/aspire · error · ArgumentException
Unknown file system entry type
Error message
Unknown file system entry type
What it means
Thrown while converting a DCP container file-system entry (file, OpenSSL certificate, or directory) into its serialized ContainerFileSystemEntry form. The switch expects only the three known entry types; any other ContainerFileSystemEntry implementation triggers this ArgumentException, indicating an internal model invariant was violated.
Solutions
- Add a new case to the switch in ToContainerFileSystemEntry mapping the new entry type to a ContainerFileSystemEntryType.
- If you did not intend a custom type, verify which object is being passed and use one of the supported entry classes (ContainerFile, ContainerOpenSSLCertificateFile, ContainerDirectory).
- Update any associated DCP schema handling so the new entry type round-trips correctly.
Example fix
// before
_ => throw new ArgumentException("Unknown file system entry type")
// after
ContainerVolumeSecret => ContainerFileSystemEntryType.Secret,
_ => throw new ArgumentException($"Unknown file system entry type: {item.GetType().Name}") Defensive patterns
Strategy: type-guard
Validate before calling
if (entry is not (ContainerFile or ContainerOpenSSLCertificateFile or ContainerDirectory))
throw new NotSupportedException($"{entry.GetType().Name} is not a supported container file entry."); Type guard
static bool IsKnownEntryType(ContainerFileSystemEntry e) => e is ContainerFile or ContainerOpenSSLCertificateFile or ContainerDirectory;
Prevention
- After adding a new DCP entry type, grep for ToContainerFileSystemEntry and update all switches.
- Add a unit test exercising all entry-type conversions.
- Avoid subclassing ContainerFileSystemEntry unless you plan to update the converters.
When it happens
Trigger: Calling ToContainerFileSystemEntry with a ContainerFileSystemEntry-derived type that is not ContainerFile, ContainerOpenSSLCertificateFile, or ContainerDirectory — effectively only possible by introducing a new DCP model type without updating this converter.
Common situations: Developers extending the DCP model with a new file-entry kind (e.g. a new certificate type) and forgetting to add the mapping case; not reachable through normal public Aspire APIs.
Related errors
- Container tunnel service
- Could not generate a unique name for service
- Custom container networks are not supported yet.
- Expected an ContainerExec resource, but got
- Service ' ' refers to endpoint ' ' that does not exist
AI-assisted analysis of microsoft/aspire@25830f84bd (2026-09-16).
Data as JSON: /api/errors/f7dde4c28f8cb972.
Report an issue: GitHub.
Appendix: source
Thrown at src/Aspire.Hosting/Dcp/Model/Container.cs:385
return Destination == other.Destination
&& DefaultOwner == other.DefaultOwner
&& DefaultGroup == other.DefaultGroup
&& Umask == other.Umask
&& (Entries ?? Enumerable.Empty<ContainerFileSystemEntry>()).SequenceEqual(other.Entries ?? Enumerable.Empty<ContainerFileSystemEntry>());
}
}
internal static class ContainerFileSystemItemExtensions
{
[AspireExportIgnore(Reason = "Internal conversion to the DCP ContainerFileSystemEntry model, which is not part of the ATS surface.")]
public static ContainerFileSystemEntry ToContainerFileSystemEntry(this ContainerFileSystemItem item)
{
var type = item switch
{
ContainerFile => ContainerFileSystemEntryType.File,
ContainerOpenSSLCertificateFile => ContainerFileSystemEntryType.OpenSSL,
ContainerDirectory => ContainerFileSystemEntryType.Directory,
_ => throw new ArgumentException("Unknown file system entry type")
};
var entry = new ContainerFileSystemEntry
{
Type = type,
Name = item.Name,
Owner = item.Owner,
Group = item.Group,
Mode = (int)item.Mode,
};
if (item is ContainerFileBase file)
{
entry.Source = file.SourcePath;
entry.Contents = file.Contents;
entry.ContinueOnError = file.ContinueOnError;
if (file.Contents is not null && file.SourcePath is not null)View on GitHub (pinned to 25830f84bd)