fix: [AH-2826]: Fixed write flows to go through existing replication in gitness#76
fix: [AH-2826]: Fixed write flows to go through existing replication in gitness#76abhinavcode wants to merge 13 commits into
Conversation
…/PROD/Harness_Commons/gitness into AH-2826-fix-merge-issue-gitness
|
No actionable comments were generated in the recent review. 🎉 📝 WalkthroughWalkthroughAdded a check in Changes
Estimated code review effort🎯 2 (Simple) | ⏱️ ~10 minutes Poem
🚥 Pre-merge checks | ✅ 2 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (2 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches
🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
There was a problem hiding this comment.
Your free trial has ended. If you'd like to continue receiving code reviews, you can add a payment method here.
There was a problem hiding this comment.
Actionable comments posted: 1
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.
Inline comments:
In `@registry/app/pkg/docker/app.go`:
- Around line 143-149: The guard is allowing GenericBlobID to drive the branch
but GetBlobStore only uses BlobID; update the condition to only check
blobLocator.BlobID != 0 (remove reference to blobLocator.GenericBlobID) so we
don't call app.bucketService.GetBlobStore with a zero blob id; locate the block
around GetOciBlobsContext and the call to app.bucketService.GetBlobStore and
change the if to rely solely on blobLocator.BlobID to match the actual semantic
use.
| if blobLocator.BlobID != 0 || blobLocator.GenericBlobID != uuid.Nil { | ||
| // For reads and lazy replication | ||
| if result := app.bucketService.GetBlobStore(c, info.RegIdentifier, info.RootIdentifier, blobLocator.BlobID, | ||
| digest.Digest(info.Digest).String()); result != nil { | ||
| ctx.OciBlobStore = result.OciStore | ||
| } | ||
| } |
There was a problem hiding this comment.
🧩 Analysis chain
🏁 Script executed:
#!/bin/bash
# Inspect BlobLocator type definition
echo "=== BlobLocator definition ==="
rg -n "type BlobLocator" --type go -A 10
echo ""
echo "=== GetBlobStore interface/function signatures ==="
rg -n "GetBlobStore" --type go -B 2 -A 5
echo ""
echo "=== Context: Show lines 143-149 in app.go ==="
sed -n '140,160p' registry/app/pkg/docker/app.goRepository: abhinavcode/harness
Length of output: 4105
🏁 Script executed:
#!/bin/bash
# Check how GetBlobStore is implemented and handles blobID=0
echo "=== Searching for GetBlobStore implementation ==="
rg -n "GetBlobStore" --type go -A 15 | head -80
echo ""
echo "=== Check context around the problematic code to understand flow ==="
sed -n '130,160p' registry/app/pkg/docker/app.go
echo ""
echo "=== Check if there are other callers of GetBlobStore ==="
rg -n "GetBlobStore\(" --type go -B 2 -A 2Repository: abhinavcode/harness
Length of output: 6678
GenericBlobID is checked in the guard but never forwarded to GetBlobStore.
The OR condition at line 143 enters the if-block when blobLocator.GenericBlobID != uuid.Nil (even when BlobID == 0), but GetBlobStore only accepts a blobID parameter of type any—there is no parameter for GenericBlobID. When BlobID is 0 and GenericBlobID is non-nil, the call passes a zero BlobID:
app.bucketService.GetBlobStore(c, info.RegIdentifier, info.RootIdentifier, blobLocator.BlobID, ...)This results in either a wasted lookup (if GetBlobStore returns nil for ID 0) or unpredictable behavior depending on the implementation.
For OCI operations (in GetOciBlobsContext), GenericBlobID is irrelevant—only BlobID (the int64 field) is semantically meaningful. The condition should be simplified to blobLocator.BlobID != 0 to match what is actually consumed.
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.
In `@registry/app/pkg/docker/app.go` around lines 143 - 149, The guard is allowing
GenericBlobID to drive the branch but GetBlobStore only uses BlobID; update the
condition to only check blobLocator.BlobID != 0 (remove reference to
blobLocator.GenericBlobID) so we don't call app.bucketService.GetBlobStore with
a zero blob id; locate the block around GetOciBlobsContext and the call to
app.bucketService.GetBlobStore and change the if to rely solely on
blobLocator.BlobID to match the actual semantic use.
Summary by CodeRabbit