Skip to content

fix: 👍 Top features/issues by Votes (updated automatically every hour)#614

Closed
abhiavi wants to merge 1 commit intobrowseros-ai:mainfrom
abhiavi:fix-issue-169-5590
Closed

fix: 👍 Top features/issues by Votes (updated automatically every hour)#614
abhiavi wants to merge 1 commit intobrowseros-ai:mainfrom
abhiavi:fix-issue-169-5590

Conversation

@abhiavi
Copy link
Copy Markdown

@abhiavi abhiavi commented Mar 28, 2026

Fix for 👍 Top features/issues by Votes (updated automatically every hour). Verified with local tests.

Co-authored-by: aider (deepseek/deepseek-chat) <aider@aider.chat>
@github-actions
Copy link
Copy Markdown
Contributor

Thank you for your contribution! Before we can merge this PR, we need you to sign our Contributor License Agreement.

To sign the CLA, please add a comment to this PR with the following text:

I have read the CLA Document and I hereby sign the CLA

You only need to sign once. After signing, this check will pass automatically.


Troubleshooting
  • Already signed but still failing? Comment recheck to trigger a re-verification.
  • Signed with a different email? Make sure your commit email matches your GitHub account email, or add your commit email to your GitHub account.
- - - I have read the CLA Document and I hereby sign the CLA - - - You can retrigger this bot by commenting **recheck** in this Pull Request. Posted by the **CLA Assistant Lite bot**.

@greptile-apps
Copy link
Copy Markdown
Contributor

greptile-apps bot commented Mar 28, 2026

Greptile Summary

This PR fixes a bug in the signature() function in compare.go where binary patches with non-empty Content (produced by parsing "Binary files … differ" diff lines) fell through to the text-processing default case, generating a content-based signature that never matched the simple "binary:path" signature produced for .binary marker files (empty-content OpBinary patches). The result was that binary patches were perpetually reported as NeedsUpdate even when they were already up-to-date.

Key changes:

  • Removed the && len(p.Content) == 0 guard from the OpBinary case in signature() so that all OpBinary patches uniformly return "binary:path".
  • Added two new unit tests (TestSignatureForBinaryPatchWithContent and TestSignatureForBinaryPatchWithoutContent) that directly verify the fix.

One follow-up to consider: patchWriteTarget in repo.go still contains the matching && len(patchFile.Content) == 0 condition, meaning OpBinary patches with content are still written as raw patch files rather than .binary markers. Since signature() now ignores that content at compare-time, the stored content becomes dead weight. Aligning the write path (always writing .binary markers for OpBinary) would keep the two paths coherent.

Confidence Score: 5/5

Safe to merge — the fix is targeted, well-tested, and corrects a clear false-positive in binary-patch comparison without introducing regressions.

The core change is a one-line simplification with a clear root cause and matching test coverage. All remaining findings are P2 style/cleanup suggestions. No correctness, data-integrity, or reliability issues remain.

packages/browseros/tools/bdev/internal/patch/repo.go — the patchWriteTarget function still has the now-inconsistent content-length guard that could be cleaned up as a follow-on.

Important Files Changed

Filename Overview
packages/browseros/tools/bdev/internal/patch/compare.go Removes the len(p.Content) == 0 guard from the OpBinary branch so all binary patches produce a consistent "binary:path" signature regardless of content, fixing false NeedsUpdate deltas.
packages/browseros/tools/bdev/internal/patch/patch_test.go Adds two unit tests — one for OpBinary with content and one without — that directly verify the fixed signature() behaviour.

Flowchart

%%{init: {'theme': 'neutral'}}%%
flowchart TD
    A["signature(p FilePatch)"] --> B{"Op == OpDelete"}
    B -- Yes --> C["return delete:path"]
    B -- No --> D{"IsPureRename"}
    D -- Yes --> E["return rename:oldPath:path"]
    D -- No --> F{"Op == OpBinary"}
    F -- "Yes - AFTER FIX all OpBinary" --> G["return binary:path"]
    F -- "No - default" --> H["content-based text signature"]
    G --> I["Consistent match: Binary files patch and .binary marker both give binary:path"]
    H --> J["BEFORE FIX: OpBinary with content fell here causing NeedsUpdate mismatch"]
Loading
Prompt To Fix All With AI
This is a comment left during a code review.
Path: packages/browseros/tools/bdev/internal/patch/repo.go
Line: 125-126

Comment:
**`patchWriteTarget` condition is now inconsistent with `signature()`**

Now that `signature()` treats all `OpBinary` patches identically (ignoring `Content`), the write path in `patchWriteTarget` has a parallel `len(patchFile.Content) == 0` guard that no longer reflects how comparison works. Binary patches *with* content are stored as raw files (with the content written to disk), but their content is now ignored at compare-time — making the stored content effectively dead weight.

Per the project's cleanup conventions, consider removing the `&& len(patchFile.Content) == 0` guard here and always writing `OpBinary` patches as `.binary` markers, consistent with how `signature()` now treats them:

```go
case patchFile.Op == OpBinary:
    return filepath.Join(patchesDir, filepath.FromSlash(patchFile.Path+".binary")), []byte("Binary file")
```

This would make the write path and compare path coherent with each other.

**Rule Used:** Remove unused/dead code rather than leaving it in ... ([source](https://app.greptile.com/review/custom-context?memory=9b045db4-2630-428c-95b7-ccf048d34547))

**Learnt From**
[browseros-ai/BrowserOS-agent#126](https://github.com/browseros-ai/BrowserOS-agent/pull/126)

How can I resolve this? If you propose a fix, please make it concise.

Reviews (1): Last reviewed commit: "fix: handle binary patches consistently ..." | Re-trigger Greptile

@Adraca
Copy link
Copy Markdown

Adraca commented Mar 30, 2026

I have read the CLA Document and I hereby sign the CLA.

@shadowfax92
Copy link
Copy Markdown
Contributor

Sorry @abhiavi the PR title and fix is completely different! can you please elaborate what is being fixed here. Thanks!

@shadowfax92 shadowfax92 closed this Apr 3, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants