Skip to content

Fix mis-matched versioning#13

Merged
Adammatthiesen merged 5 commits intomainfrom
debug-zod-error
Jul 29, 2025
Merged

Fix mis-matched versioning#13
Adammatthiesen merged 5 commits intomainfrom
debug-zod-error

Conversation

@Adammatthiesen
Copy link
Member

@Adammatthiesen Adammatthiesen commented Jul 29, 2025

Description

Summary by CodeRabbit

  • Bug Fixes

    • Corrected validation for version numbers to properly match the expected format in metric IDs.
    • Updated schema validation to support IDs starting with "v5-" instead of "v4-".
  • Tests

    • Updated test data and comments to use the new "v5-" prefix for metric IDs.

@changeset-bot
Copy link

changeset-bot bot commented Jul 29, 2025

🦋 Changeset detected

Latest commit: 446fefb

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 1 package
Name Type
@studiocms/web-vitals Patch

Not sure what this means? Click here to learn what changesets are.

Click here if you're a maintainer who wants to add another changeset to this PR

@coderabbitai
Copy link
Contributor

coderabbitai bot commented Jul 29, 2025

Walkthrough

This change updates the regular expression and transformation logic for metric ID validation in the web-vitals package, shifting from "v4-" to "v5-" prefixes. Associated test data and documentation are also updated to match the new versioning scheme, resolving schema validation errors.

Changes

Cohort / File(s) Change Summary
Schema Regex Update
packages/web-vitals/src/schemas.ts
Updated the regex and transformation logic for MetricIdSchema to expect and process "v5-" prefixes instead of "v4-".
Test Data Update
packages/web-vitals/test/basics.test.js
Updated all test metric IDs and comments from "v4-" to "v5-" to align with new schema expectations.
Documentation/Changelog
.changeset/twelve-bars-type.md
Added a changeset entry describing the patch to the regex for version number validation.

Sequence Diagram(s)

sequenceDiagram
    participant Client
    participant Endpoint
    participant ZodSchema

    Client->>Endpoint: Submit metric payload with ID (e.g., "v5-...")
    Endpoint->>ZodSchema: Validate metric ID with updated regex ("v5-" prefix)
    ZodSchema-->>Endpoint: Validation success/failure
    Endpoint-->>Client: Respond with success or error
Loading

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~8 minutes

Assessment against linked issues

Objective Addressed Explanation
Fix Zod schema regex to resolve validation errors for metric IDs (#12)

Possibly related PRs

Poem

A regex hopped from four to five,
Now metric IDs will surely thrive.
No more Zod errors in the night,
Web vitals' future’s looking bright!
🐇✨

With every patch, we leap ahead—
Bugs behind, green tests instead!

Note

⚡️ Unit Test Generation is now available in beta!

Learn more here, or try it out under "Finishing Touches" below.


📜 Recent review details

Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 17bed51 and 446fefb.

📒 Files selected for processing (3)
  • .changeset/twelve-bars-type.md (1 hunks)
  • packages/web-vitals/src/schemas.ts (1 hunks)
  • packages/web-vitals/test/basics.test.js (3 hunks)
🔇 Additional comments (5)
packages/web-vitals/src/schemas.ts (1)

10-13: LGTM! Coordinated schema and transformation updates.

The changes correctly update both the regex validation pattern and the transformation logic to handle v5- prefixed IDs consistently. The regex pattern /^v5-\d{13}-\d{13}$/ properly validates the expected format, and the transformation logic correctly truncates the timestamp while preserving the new prefix.

packages/web-vitals/test/basics.test.js (3)

115-115: Test data updated correctly for v5- prefix.

The input test data has been updated to use the new v5- prefix format, which aligns with the schema changes.


139-139: Expected result correctly shows timestamp truncation.

The expected database result correctly demonstrates the timestamp truncation behavior - the input ID v5-1711484350895-3748043125387 is transformed to v5-17114843-3748043125387 with 5 digits removed from the middle timestamp, matching the schema transformation logic.


150-152: Comments and assertions updated consistently.

The comment and assertion have been properly updated to reflect the new v5- prefix format and demonstrate the timestamp truncation behavior.

.changeset/twelve-bars-type.md (1)

1-6: Changeset accurately documents the fix.

The changeset correctly identifies this as a patch-level change to fix the Zod regex validation issue caused by version number mismatch. The description accurately captures the nature of the problem and solution.

✨ Finishing Touches
  • 📝 Generate Docstrings
🧪 Generate unit tests
  • Create PR with unit tests
  • Post copyable unit tests in a comment
  • Commit unit tests in branch debug-zod-error

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.

❤️ Share
🪧 Tips

Chat

There are 3 ways to chat with CodeRabbit:

  • Review comments: Directly reply to a review comment made by CodeRabbit. Example:
    • I pushed a fix in commit <commit_id>, please review it.
    • Explain this complex logic.
    • Open a follow-up GitHub issue for this discussion.
  • Files and specific lines of code (under the "Files changed" tab): Tag @coderabbitai in a new review comment at the desired location with your query. Examples:
    • @coderabbitai explain this code block.
    • @coderabbitai modularize this function.
  • PR comments: Tag @coderabbitai in a new PR comment to ask questions about the PR branch. For the best results, please provide a very specific query, as very limited context is provided in this mode. Examples:
    • @coderabbitai gather interesting stats about this repository and render them as a table. Additionally, render a pie chart showing the language distribution in the codebase.
    • @coderabbitai read src/utils.ts and explain its main purpose.
    • @coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.
    • @coderabbitai help me debug CodeRabbit configuration file.

Support

Need help? Create a ticket on our support page for assistance with any issues or questions.

Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments.

CodeRabbit Commands (Invoked using PR comments)

  • @coderabbitai pause to pause the reviews on a PR.
  • @coderabbitai resume to resume the paused reviews.
  • @coderabbitai review to trigger an incremental review. This is useful when automatic reviews are disabled for the repository.
  • @coderabbitai full review to do a full review from scratch and review all the files again.
  • @coderabbitai summary to regenerate the summary of the PR.
  • @coderabbitai generate docstrings to generate docstrings for this PR.
  • @coderabbitai generate sequence diagram to generate a sequence diagram of the changes in this PR.
  • @coderabbitai generate unit tests to generate unit tests for this PR.
  • @coderabbitai resolve resolve all the CodeRabbit review comments.
  • @coderabbitai configuration to show the current CodeRabbit configuration for the repository.
  • @coderabbitai help to get help.

Other keywords and placeholders

  • Add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.
  • Add @coderabbitai summary to generate the high-level summary at a specific location in the PR description.
  • Add @coderabbitai anywhere in the PR title to generate the title automatically.

CodeRabbit Configuration File (.coderabbit.yaml)

  • You can programmatically configure CodeRabbit by adding a .coderabbit.yaml file to the root of your repository.
  • Please see the configuration documentation for more information.
  • If your editor has YAML language server enabled, you can add the path at the top of this file to enable auto-completion and validation: # yaml-language-server: $schema=https://coderabbit.ai/integrations/schema.v2.json

Documentation and Community

  • Visit our Documentation for detailed information on how to use CodeRabbit.
  • Join our Discord Community to get help, request features, and share feedback.
  • Follow us on X/Twitter for updates and announcements.

@pkg-pr-new
Copy link

pkg-pr-new bot commented Jul 29, 2025

Open in StackBlitz

npm i https://pkg.pr.new/withstudiocms/web-vitals/@studiocms/web-vitals@13

commit: 446fefb

@Adammatthiesen Adammatthiesen changed the title add console logs for testing Fix mis-matched versioning Jul 29, 2025
@Adammatthiesen Adammatthiesen marked this pull request as ready for review July 29, 2025 10:07
@Adammatthiesen Adammatthiesen requested a review from a team as a code owner July 29, 2025 10:07
@Adammatthiesen Adammatthiesen merged commit 8d6e89b into main Jul 29, 2025
8 checks passed
@Adammatthiesen Adammatthiesen deleted the debug-zod-error branch July 29, 2025 10: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.

[Bug]: Zod Error from endpoint

2 participants