Skip to content

Enforce strict shipping tag parsing across product reads#341

Merged
calvadev merged 4 commits intoshopstr-eng:mainfrom
vagxrth:fix/strict-shipping-parser
Apr 14, 2026
Merged

Enforce strict shipping tag parsing across product reads#341
calvadev merged 4 commits intoshopstr-eng:mainfrom
vagxrth:fix/strict-shipping-parser

Conversation

@vagxrth
Copy link
Copy Markdown
Contributor

@vagxrth vagxrth commented Apr 5, 2026

Description

  • Enforced strict parsing for product shipping tags so only the modern format ["shipping", type, cost, currency] is accepted.
  • Added a shared shipping tag helper to centralize validation and effective shipping cost calculation.
  • Updated the canonical product parser to ignore deprecated legacy 1-value and 2-value shipping tags instead of interpreting them.
  • Aligned the MCP read paths and catalog resource parsing with the canonical parser so shipping behavior is consistent across all read surfaces.
  • Added regression tests covering:
    • valid modern shipping tags
    • ignored legacy 2-value shipping tags
    • ignored legacy 1-value shipping tags
    • ignored malformed shipping tags with non-numeric costs
    • safe handling of missing/invalid shipping metadata in pricing calculations

Resolved or fixed issue

Fixes #275

Screenshots (if applicable)

none

Affirmation

@vercel
Copy link
Copy Markdown

vercel bot commented Apr 5, 2026

@vagxrth is attempting to deploy a commit to the shopstr-eng Team on Vercel.

A member of the Team first needs to authorize it.

@vagxrth
Copy link
Copy Markdown
Contributor Author

vagxrth commented Apr 5, 2026

@calvadev @GautamBytes can you review this PR?

Copy link
Copy Markdown
Contributor

@kaihere14 kaihere14 left a comment

Choose a reason for hiding this comment

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

Good cleanup, centralizing the shipping logic makes sense. A couple things:

  • getEffectiveShippingCost returns 0 for both malformed tags and genuinely free shipping — callers can't tell
    the difference. Worth returning null for the missing case.
  • Negative costs will pass Number.isFinite() — add a >= 0 check in parseShippingTag.
  • Quick grep worth doing to make sure no components are still doing raw tag[1]/tag[2] access and bypassing the
    new helper.

Tests look solid otherwise. LGTM with those addressed

@GautamBytes GautamBytes self-requested a review April 7, 2026 08:15
@GautamBytes
Copy link
Copy Markdown
Contributor

@vagxrth please address first 2 comments of @kaihere14 and solve merge conflict then its good to merge

@vagxrth vagxrth requested a review from kaihere14 April 9, 2026 08:31
@GautamBytes
Copy link
Copy Markdown
Contributor

LGTM

Copy link
Copy Markdown
Contributor

@kaihere14 kaihere14 left a comment

Choose a reason for hiding this comment

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

Lgtm tooo

@calvadev calvadev merged commit 3e6dfff into shopstr-eng:main Apr 14, 2026
1 check failed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Cleanup] Remove deprecated legacy shipping tag parsing logic

4 participants