{"record":{"id":"928d35c8264a75d3","repo":"dagger/dagger","slug":"function-q-completed-without-returning-a-value","errorCode":null,"errorMessage":"function %q completed without returning a value","messagePattern":"function %q completed without returning a value","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"core/modfunc.go","lineNumber":923,"sourceCode":"\tif returnStateErr != nil {\n\t\treturn nil, returnStateErr\n\t}\n\tif err != nil {\n\t\tif returnedSet && returned.HasError {\n\t\t\tdagErr, loadErr := functionCallReturnedError(ctx, returned.ErrorID, err)\n\t\t\tif loadErr != nil {\n\t\t\t\treturn nil, loadErr\n\t\t\t}\n\t\t\treturn nil, dagErr\n\t\t}\n\t\treturn nil, err\n\t}\n\n\tif !returnedSet {\n\t\tif fnCall.Name == \"\" {\n\t\t\treturn nil, fmt.Errorf(\"constructor completed without returning a value\")\n\t\t}\n\t\treturn nil, fmt.Errorf(\"function %q completed without returning a value\", fnCall.Name)\n\t}\n\tif returned.HasError {\n\t\tdagErr, err := functionCallReturnedError(ctx, returned.ErrorID, nil)\n\t\tif err != nil {\n\t\t\treturn nil, err\n\t\t}\n\t\treturn nil, dagErr\n\t}\n\n\treturnValue, err := fn.returnType.ConvertFromSDKResult(ctx, returned.Value)\n\tif err != nil {\n\t\treturn nil, fmt.Errorf(\"convert return value: %w\", err)\n\t}\n\n\tif returnValue != nil && fn.hasWorkspaceArgs() {\n\t\treturnType := fn.returnType\n\t\tfor nullable, ok := returnType.(*NullableType); ok; nullable, ok = returnType.(*NullableType) {\n\t\t\treturnType = nullable.Inner","sourceCodeStart":905,"sourceCodeEnd":941,"githubUrl":"https://github.com/dagger/dagger/blob/82ba2681dbe30d3547a1dc50ea495900ab5b6047/core/modfunc.go#L905-L941","documentation":"A named module function finished executing but did not report returning any value. Every function whose declared return type is not void must set a return value via the function call protocol; when execution completes with no return set, Dagger rejects the result with this error naming the function.","triggerScenarios":"Calling a module function whose implementation exits without calling the SDK's return-result API (e.g. code path that panics-then-recovers, drops the return, or the SDK runtime fails to report the result).","commonSituations":"Branching logic in the function that skips the return statement; SDK version mismatch where result reporting is broken; async work still pending when the function process exits.","solutions":["Ensure the function returns a value on every code path","Check that the function's declared return type is not void when you expect to return data","Upgrade the module SDK to a version matching the CLI engine"],"exampleFix":"// before\nfunc (m *MyMod) Do(ctx context.Context) (string, error) {\n    if m.skip {\n        return // syntax bug: no return value\n    }\n}\n// after\nfunc (m *MyMod) Do(ctx context.Context) (string, error) {\n    if m.skip {\n        return \"\", nil\n    }\n    return \"done\", nil\n}","handlingStrategy":"try-catch","validationCode":null,"typeGuard":null,"tryCatchPattern":"res, err := fn.Call(ctx, parent, inputs)\nif err != nil {\n    if strings.Contains(err.Error(), \"completed without returning a value\") {\n        // function implementation missed its return; fix SDK function\n    }\n    return err\n}","preventionTips":["Ensure every branch of a function returns a value","Match declared return type vs actual returns (void only if declared void)","Write integration tests covering all branches of module functions","Keep SDK versions current so result reporting works"],"tags":["modules","return-value","functions"],"backgroundTag":"missing-return-value","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"}