Skip to content

Conversation

@seefeldb
Copy link
Contributor

@seefeldb seefeldb commented Oct 16, 2025

Move data URI inlining logic to occur before write redirect (alias) handling in normalizeAndDiff. This ensures the correct evaluation order when a data URI contains a redirect link.

Previously, when newValue was a data URI containing a redirect, the code would:

  1. Check currentValue for redirects (line 290)
  2. Follow currentValue redirect if present
  3. Process data URI inlining later (line 318)

This caused the redirect within the data URI to be written to the wrong location - it would follow the currentValue redirect first, then inline the data URI, resulting in the redirect being written to the destination of the currentValue alias instead of to the intended target.

The fix reorders the logic so data URIs are inlined immediately after unwrapping proxies and cells (line 212), before any redirect handling. This preserves the invariant that redirect handling at line 290 only applies when newValue is not itself an alias.

The order is now:

  1. Unwrap proxies/cells
  2. Inline data URIs (exposing any contained redirects)
  3. Handle redirects in newValue
  4. Handle redirects in currentValue

This ensures redirects contained in data URIs are properly recognized and handled as part of newValue, not incorrectly written through a currentValue redirect.


Summary by cubic

Fixes incorrect write redirects when newValue is a data: URI by inlining it before any redirect handling. Redirects inside data URIs now apply to the intended target, not through the currentValue alias.

  • Bug Fixes
    • Inline data: URIs right after unwrapping proxies/cells in normalizeAndDiff.
    • New order: unwrap → inline data → handle newValue redirects → handle currentValue redirects.
    • Prevents writing data-URI redirects to the currentValue alias destination.

Move data URI inlining logic to occur before write redirect (alias)
handling in normalizeAndDiff. This ensures the correct evaluation order
when a data URI contains a redirect link.

Previously, when newValue was a data URI containing a redirect, the
code would:
1. Check currentValue for redirects (line 290)
2. Follow currentValue redirect if present
3. Process data URI inlining later (line 318)

This caused the redirect within the data URI to be written to the wrong
location - it would follow the currentValue redirect first, then inline
the data URI, resulting in the redirect being written to the destination
of the currentValue alias instead of to the intended target.

The fix reorders the logic so data URIs are inlined immediately after
unwrapping proxies and cells (line 212), before any redirect handling.
This preserves the invariant that redirect handling at line 290 only
applies when newValue is not itself an alias.

The order is now:
1. Unwrap proxies/cells
2. Inline data URIs (exposing any contained redirects)
3. Handle redirects in newValue
4. Handle redirects in currentValue

This ensures redirects contained in data URIs are properly recognized
and handled as part of newValue, not incorrectly written through a
currentValue redirect.
@seefeldb seefeldb requested review from Copilot, ellyxir and ubik2 October 16, 2025 19:45
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull Request Overview

This PR fixes a bug in the normalizeAndDiff function where data URIs containing redirect links were being written to incorrect locations. The fix reorders the processing logic to inline data URIs immediately after unwrapping proxies/cells and before handling any redirect (alias) logic.

Key changes:

  • Moved data URI inlining logic from line 318 to line 212, executing it earlier in the evaluation sequence
  • Relocated helper function isImmediateParent and diffLogger constant to improve code organization
  • Preserved all existing functionality while fixing the evaluation order bug

Tip: Customize your code reviews with copilot-instructions.md. Create the file or learn how to get started.

Copy link
Contributor

@cubic-dev-ai cubic-dev-ai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No issues found across 2 files

Copy link
Contributor

@ellyxir ellyxir left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

lgtm

@ellyxir
Copy link
Contributor

ellyxir commented Oct 16, 2025

fixes my broken pattern, thanks!

@seefeldb seefeldb merged commit 1867bf7 into main Oct 16, 2025
9 checks passed
@seefeldb seefeldb deleted the fix/inline-data-uri-on-write branch October 16, 2025 21:56
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.

4 participants