{"record":{"id":"77152a49409c30fc","repo":"dagger/dagger","slug":"service-digest-is-empty","errorCode":null,"errorMessage":"service digest is empty","messagePattern":"service digest is empty","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"core/service.go","lineNumber":342,"sourceCode":"\t\treturn \"\", err\n\t}\n\n\tswitch {\n\tcase svc.TunnelUpstream.Self() != nil: // host=>container (127.0.0.1)\n\t\tsvcs, err := query.Services(ctx)\n\t\tif err != nil {\n\t\t\treturn \"\", err\n\t\t}\n\t\tupstream, err := svcs.Get(ctx, dig, true)\n\t\tif err != nil {\n\t\t\treturn \"\", err\n\t\t}\n\n\t\treturn upstream.Host, nil\n\tcase svc.Container.Self() != nil, // container=>container\n\t\tlen(svc.HostSockets) > 0: // container=>host\n\t\tif dig == \"\" {\n\t\t\treturn \"\", errors.New(\"service digest is empty\")\n\t\t}\n\t\treturn network.HostHash(dig), nil\n\tdefault:\n\t\treturn \"\", errors.New(\"unknown service type\")\n\t}\n}\n\nfunc (svc *Service) Ports(ctx context.Context, dig digest.Digest) ([]Port, error) {\n\tquery, err := CurrentQuery(ctx)\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\n\tswitch {\n\tcase svc.TunnelUpstream.Self() != nil, len(svc.HostSockets) > 0:\n\t\tsvcs, err := query.Services(ctx)\n\t\tif err != nil {\n\t\t\treturn nil, err","sourceCodeStart":324,"sourceCodeEnd":360,"githubUrl":"https://github.com/dagger/dagger/blob/82ba2681dbe30d3547a1dc50ea495900ab5b6047/core/service.go#L324-L360","documentation":"Service.Hostname computes a deterministic DNS hostname from a content digest for container=>container or container=>host services, but was handed an empty digest. Without a digest there is nothing to hash into a host name, so it fails with this error. Callers (Endpoint, startContainer, startReverseTunnel) normally derive the digest from the service registration, so an empty dig means the service was looked up before registration.","triggerScenarios":"Calling Hostname (directly or via Service.Endpoint / when starting a container or reverse tunnel) with dig == \"\" while the service is a container service or has HostSockets — e.g. querying Endpoint on a service that was never evaluated/registered in the services registry for the current query.","commonSituations":"Calling Endpoint/hostname on a Service obtained but not yet started or evaluated; custom module code invoking endpoint APIs before binding the service to a container; services referenced across queries without re-registration.","solutions":["Evaluate/start the service (or call it via Container.WithServiceBinding and use the dependent container's Endpoint) so a digest is registered before requesting the hostname.","Use the documented API surface (Container.Endpoint / Service endpoints via SDK) instead of calling Hostname with a manually supplied digest.","If using a custom hostname, set it with WithHostname so the digest path is bypassed."],"exampleFix":"// before\nhost, _ := svc.Hostname(ctx, \"\") // empty digest\n// after\nhost, err := containerWithSvc.Endpoint(ctx) // let the engine resolve the registered digest","handlingStrategy":"validation","validationCode":"dig := serviceDigest(svc) // from service registration\nif dig == \"\" {\n    // evaluate/start the service first, or use the dependent container's Endpoint API\n    return errors.New(\"service not registered; cannot compute hostname\")\n}","typeGuard":null,"tryCatchPattern":"if err != nil && strings.Contains(err.Error(), \"service digest is empty\") {\n    // evaluate the service (e.g. run a dependent container) then retry the endpoint lookup\n}","preventionTips":["Use SDK-level Endpoint APIs on evaluated containers instead of calling core Hostname directly.","Ensure services are started/registered before querying hostnames.","Set an explicit hostname via WithHostname when you need a stable name."],"tags":["service","hostname","network","endpoint"],"backgroundTag":"empty-service-digest","analyzedSha":"82ba2681dbe30d3547a1dc50ea495900ab5b6047","analyzedAt":"2026-09-05T07:21:37.930Z","contentChangedAt":"2026-09-05T07:21:37.930Z","schemaVersion":2},"datasetVersion":"2026-09-12T12:17:11.808Z"}