Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

🐛 Fix decoder bug when option value encoding does not end with a control character #2721

Open
wants to merge 2 commits into
base: main
Choose a base branch
from

Conversation

lhoffbeck
Copy link
Contributor

WHY are these changes introduced?

The decoder did not correctly handle the case of an encoding ending with an index, and either no previous control chars OR a char.

Examples:

  • V1_0 incorrectly decoded to [] instead of [[0]]
  • V1_0 5 incorrectly decoded to [[0]] instead of [[0], [5]]

WHAT is this pull request doing?

The root of the problem is that the decoder processes tokens and then does a look-back to grab the index to process. If the final char of the encoding is not a control char, it never looks back. We previously handled this with an exception for the range case but missed the case where a range char is not present.

This PR adds a more generic handler for encodings that end with an index.

Q: The exception handler only accounts for no control char, a - or a . Don't we need to handle : and , too?
A: No. If an encoded string contains a : or a , anywhere, the string will always end with a ,.

HOW to test your changes?

Do tests pass?

Post-merge steps

Checklist

  • I've read the Contributing Guidelines
  • I've considered possible cross-platform impacts (Mac, Linux, Windows)
  • I've added a changeset if this PR contains user-facing or noteworthy changes
  • I've added tests to cover my changes
  • I've added or updated the documentation

This comment has been minimized.

Copy link
Contributor

shopify bot commented Jan 23, 2025

Oxygen deployed a preview of your lh-bugfix-for-option-value-decoder branch. Details:

Storefront Status Preview link Deployment details Last update (UTC)
custom-cart-method ✅ Successful (Logs) Preview deployment Inspect deployment January 23, 2025 4:58 PM
classic-remix ✅ Successful (Logs) Preview deployment Inspect deployment January 23, 2025 4:58 PM
Skeleton (skeleton.hydrogen.shop) ✅ Successful (Logs) Preview deployment Inspect deployment January 23, 2025 4:58 PM
third-party-queries-caching ✅ Successful (Logs) Preview deployment Inspect deployment January 23, 2025 4:58 PM
metaobjects ✅ Successful (Logs) Preview deployment Inspect deployment January 23, 2025 4:58 PM

Learn more about Hydrogen's GitHub integration.

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.

2 participants