{"record":{"id":"66726f4dc9370565","repo":"dagger/dagger","slug":"received-uncommitted-patch-before-metadata","errorCode":null,"errorMessage":"received uncommitted patch before metadata","messagePattern":"received uncommitted patch before metadata","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"engine/engineutil/client.go","lineNumber":764,"sourceCode":"\t\t\t\treturn nil, fmt.Errorf(\"received more than one uncommitted metadata message\")\n\t\t\t}\n\t\t\tif errInfo := msg.Metadata.GetError(); errInfo != nil {\n\t\t\t\tswitch errInfo.Type {\n\t\t\t\tcase git.NOT_A_REPO:\n\t\t\t\t\treturn nil, fmt.Errorf(\"%s: %w\", errInfo.Message, gitutil.ErrGitNoRepo)\n\t\t\t\tcase git.NOT_FOUND, git.UNCOMMITTED_UNSUPPORTED:\n\t\t\t\t\treturn nil, fmt.Errorf(\"%s: %w\", errInfo.Message, ErrGitUncommittedUnsupported)\n\t\t\t\tdefault:\n\t\t\t\t\treturn nil, errors.New(errInfo.Message)\n\t\t\t\t}\n\t\t\t}\n\t\t\tpack = &GitUncommittedPack{\n\t\t\t\tHeadSHA:            msg.Metadata.HeadSha,\n\t\t\t\tNestedRepositories: append([]string(nil), msg.Metadata.NestedRepositories...),\n\t\t\t}\n\t\tcase *git.PackUncommittedResponse_Chunk:\n\t\t\tif pack == nil {\n\t\t\t\treturn nil, fmt.Errorf(\"received uncommitted patch before metadata\")\n\t\t\t}\n\t\t\tif spool == nil {\n\t\t\t\tspool, err = newGitPackSpool(\"dagger-uncommitted-pack-*\", git.MaxGitPackBytes)\n\t\t\t\tif err != nil {\n\t\t\t\t\treturn nil, fmt.Errorf(\"create uncommitted pack spool: %w\", err)\n\t\t\t\t}\n\t\t\t}\n\t\t\tif err := spool.write(msg.Chunk); err != nil {\n\t\t\t\treturn nil, fmt.Errorf(\"receive uncommitted pack: %w\", err)\n\t\t\t}\n\t\t}\n\t}\n\tif pack == nil {\n\t\treturn nil, fmt.Errorf(\"missing uncommitted pack metadata message\")\n\t}\n\tif pack.HeadSHA != expectedHeadSHA {\n\t\treturn nil, fmt.Errorf(\"uncommitted pack HEAD %s does not match expected %s\", pack.HeadSHA, expectedHeadSHA)\n\t}","sourceCodeStart":746,"sourceCodeEnd":782,"githubUrl":"https://github.com/dagger/dagger/blob/82ba2681dbe30d3547a1dc50ea495900ab5b6047/engine/engineutil/client.go#L746-L782","documentation":"PackGitUncommitted expects a gRPC stream where the first message is always the Metadata message and subsequent messages are patch Chunks. If a Chunk arrives before any Metadata message, the client cannot know the HEAD SHA or nested repositories and aborts with this protocol-violation error. It indicates the server sent messages out of order or a non-conforming stream.","triggerScenarios":"The server-side git service streams a PackUncommittedResponse_Chunk as the first message instead of PackUncommittedResponse_Metadata — typically a bug or version mismatch in the engine's git streaming implementation.","commonSituations":"Engine/client version skew where the message ordering contract changed; a custom or patched engine emitting chunks first; race or corruption in the gRPC stream delivery.","solutions":["Ensure engine and dagger CLI/SDK versions match (dagger engine upgrade in lockstep)","Retry the operation once — transient stream corruption is rare but possible","Fall back to directory-sync-based loading if available, since PackGitUncommitted is an optimization","File a bug with engine logs if reproducible; this is a server-side protocol violation"],"exampleFix":null,"handlingStrategy":"retry","validationCode":null,"typeGuard":null,"tryCatchPattern":"var pack *GitUncommittedPack\nvar err error\nfor i := 0; i < 2; i++ {\n\tpack, err = client.PackGitUncommitted(ctx, path, sha)\n\tif err == nil || !strings.Contains(err.Error(), \"before metadata\") {\n\t\tbreak\n\t}\n\ttime.Sleep(time.Second) // protocol violation may be transient stream corruption\n}","preventionTips":["Upgrade engine and CLI/SDK together — this is a protocol contract violation","Pin engine version per project so message ordering assumptions hold","Report reproducible occurrences with engine logs; it indicates an engine bug"],"tags":["git","grpc","protocol-violation","streaming"],"backgroundTag":"grpc-stream-order-violation","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"}