dagger/dagger · error
no media type is stored for %q
Error message
no media type is stored for %q
What it means
getBlobDesc reconstructs an OCI descriptor from a blob's content-store metadata. The blob's media type is stored as a label (blobMediaTypeLabel) on the content record; if the record exists but lacks that label, the media type cannot be recovered and this error is thrown. It indicates the blob was stored without full descriptor metadata, typically by older versions or by paths that wrote blobs directly.
Source
Thrown at engine/snapshots/refs.go:545
}
if isContinue, err := walkBlobVariantsOnly(ctx, cs, c, f, visited); !isContinue || err != nil {
return isContinue, err
}
}
return true, nil
}
func getBlobDesc(ctx context.Context, cs content.Store, dgst digest.Digest) (ocispecs.Descriptor, error) {
info, err := cs.Info(ctx, dgst)
if err != nil {
return ocispecs.Descriptor{}, err
}
if info.Labels == nil {
return ocispecs.Descriptor{}, errors.Errorf("no blob metadata is stored for %q", info.Digest)
}
mt, ok := info.Labels[blobMediaTypeLabel]
if !ok {
return ocispecs.Descriptor{}, errors.Errorf("no media type is stored for %q", info.Digest)
}
desc := ocispecs.Descriptor{
Digest: info.Digest,
Size: info.Size,
MediaType: mt,
}
for k, v := range info.Labels {
if strings.HasPrefix(k, blobAnnotationsLabelPrefix) {
if desc.Annotations == nil {
desc.Annotations = make(map[string]string)
}
desc.Annotations[strings.TrimPrefix(k, blobAnnotationsLabelPrefix)] = v
}
}
if len(desc.URLs) == 0 {
// If there are no URL's, there is no reason to have this be non-dsitributable
desc.MediaType = layerToDistributable(desc.MediaType)
}View on GitHub (pinned to 82ba2681db)
Solutions
- Re-push or re-ingest the affected blob so addBlobDescToInfo writes the media-type label
- Run a migration/GC-prune of the content store to drop legacy unlabeled blobs
- Skip blobs missing the label in walkBlobVariantsOnly rather than failing the whole walk
Example fix
// before
desc, err := getBlobDesc(ctx, cs, dgst) // errors on unlabeled blob
// after
if _, err := cs.Info(ctx, dgst); err == nil {
info, _ := cs.Info(ctx, dgst)
if info.Labels == nil || info.Labels[blobMediaTypeLabel] == "" {
info = addBlobDescToDesc(desc, info) // backfill label before querying
cs.Update(ctx, info, "labels."+blobMediaTypeLabel)
}
}
desc, err := getBlobDesc(ctx, cs, dgst) Defensive patterns
Strategy: type-guard
Validate before calling
info, err := cs.Info(ctx, dgst)
if err != nil { return err }
if info.Labels == nil || info.Labels[blobMediaTypeLabel] == "" {
// legacy/unlabeled blob: backfill or skip
info = addBlobDescToInfo(desc, info)
if _, err := cs.Update(ctx, info, "labels."+blobMediaTypeLabel); err != nil { return err }
} Type guard
func hasBlobMediaType(info content.Info) bool {
return info.Labels != nil && info.Labels[blobMediaTypeLabel] != ""
} Try / catch
desc, err := getBlobDesc(ctx, cs, dgst)
if err != nil && strings.Contains(err.Error(), "no media type is stored") {
// fall back to default layer media type or skip variant
} Prevention
- Always write blobs through paths that call addBlobDescToInfo
- After engine upgrades, run a migration over stored blobs to add missing labels
- In walker code, skip-not-fail on unlabeled variants
When it happens
Trigger: Calling getBlobDesc (via ociDesc or walkBlobVariantsOnly) on a content-store blob whose Info.Labels map exists but has no blobMediaTypeLabel key — e.g. blobs ingested by a containerd/dagger version that did not stamp media-type labels, or GC-rebuilt metadata.
Common situations: Upgrading from an older engine whose stored blobs predate the blobMediaTypeLabel convention; inspecting/exporting caches created by another tool that populated the content store directly.
Related errors
- read index blob: %w
- stat host manifest %s: %w
- read host image index blob: %w
- error writing manifest list blob %s
- error writing manifest blob %s
AI-assisted analysis of dagger/dagger@82ba2681db (2026-09-05).
Data as JSON: /api/errors/3d87304ea42588ac.
Report an issue: GitHub.