Skip to content

Conversation

@iuwqyir
Copy link
Contributor

@iuwqyir iuwqyir commented Jun 18, 2025

Fixes validation for query params that can be single or multiple value.
E.g. ?contract_address=0x...&contract_address=0x.. and ?contract_address=0x.. are both valid queries. Doing just 1 value as in the second variant did not pass validation previously, but now does


PR-Codex overview

This PR refines the schema validation logic in the blueprint-playground.client.tsx file. It modifies how required items are handled in an array schema and introduces a union type for better flexibility.

Detailed summary

  • Changed the return value for when isRequired is true to use z.union to allow either an array or a single item schema.
  • Made the array schema always required when isRequired is true.
  • Made the array schema optional when isRequired is false.

✨ Ask PR-Codex anything about this PR by commenting with /codex {your question}

Summary by CodeRabbit

  • New Features
    • Enhanced form input flexibility to accept either a single item or an array of items for array-typed parameters.

@changeset-bot
Copy link

changeset-bot bot commented Jun 18, 2025

⚠️ No Changeset found

Latest commit: a1d8373

Merging this PR will not cause a version bump for any packages. If these changes should not result in a new version, you're good to go. If these changes should result in a version bump, you need to add a changeset.

This PR includes no changesets

When changesets are added to this PR, you'll see the packages that this PR includes changesets for and the associated semver types

Click here to learn what changesets are, and how to add one.

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

@vercel vercel bot temporarily deployed to Preview – wallet-ui June 18, 2025 20:29 Inactive
@vercel
Copy link

vercel bot commented Jun 18, 2025

The latest updates on your projects. Learn more about Vercel for Git ↗︎

Name Status Preview Comments Updated (UTC)
thirdweb_playground ✅ Ready (Inspect) Visit Preview 💬 Add feedback Jun 18, 2025 9:22pm
5 Skipped Deployments
Name Status Preview Comments Updated (UTC)
docs-v2 ⬜️ Skipped (Inspect) Jun 18, 2025 9:22pm
login ⬜️ Skipped (Inspect) Jun 18, 2025 9:22pm
nebula ⬜️ Skipped (Inspect) Jun 18, 2025 9:22pm
thirdweb-www ⬜️ Skipped (Inspect) Jun 18, 2025 9:22pm
wallet-ui ⬜️ Skipped (Inspect) Jun 18, 2025 9:22pm

@vercel vercel bot temporarily deployed to Preview – nebula June 18, 2025 20:29 Inactive
@vercel vercel bot temporarily deployed to Preview – thirdweb-www June 18, 2025 20:29 Inactive
@vercel vercel bot temporarily deployed to Preview – docs-v2 June 18, 2025 20:29 Inactive
@vercel vercel bot temporarily deployed to Preview – login June 18, 2025 20:29 Inactive
@coderabbitai
Copy link
Contributor

coderabbitai bot commented Jun 18, 2025

Walkthrough

The change updates the array type handling within the openAPIV3ParamToZodFormSchema function. The function now generates a schema that accepts either a single item or an array of items for parameters defined as arrays, using a union schema to accommodate both input types.

Changes

File Change Summary
apps/playground-web/src/app/insight/[blueprint_slug]/blueprint-playground.client.tsx Modified array type schema logic in openAPIV3ParamToZodFormSchema to accept both single items and arrays via a union schema.

Suggested reviewers

  • jnsdls
  • MananTank

📜 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 7871e40 and a1d8373.

📒 Files selected for processing (1)
  • apps/playground-web/src/app/insight/[blueprint_slug]/blueprint-playground.client.tsx (1 hunks)
🚧 Files skipped from review as they are similar to previous changes (1)
  • apps/playground-web/src/app/insight/[blueprint_slug]/blueprint-playground.client.tsx
⏰ Context from checks skipped due to timeout of 90000ms (8)
  • GitHub Check: E2E Tests (pnpm, esbuild)
  • GitHub Check: E2E Tests (pnpm, webpack)
  • GitHub Check: E2E Tests (pnpm, vite)
  • GitHub Check: Size
  • GitHub Check: Build Packages
  • GitHub Check: Unit Tests
  • GitHub Check: Lint Packages
  • GitHub Check: Analyze (javascript)
✨ Finishing Touches
  • 📝 Generate Docstrings

🪧 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 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.

@github-actions github-actions bot added the Playground Changes involving the Playground codebase. label Jun 18, 2025
Copy link
Contributor Author

iuwqyir commented Jun 18, 2025


How to use the Graphite Merge Queue

Add either label to this PR to merge it via the merge queue:

  • merge-queue - adds this PR to the back of the merge queue
  • hotfix - for urgent hot fixes, skip the queue and merge this PR next

You must have a Graphite account in order to use the merge queue. Sign up using this link.

An organization admin has enabled the Graphite Merge Queue in this repository.

Please do not merge from GitHub as this will restart CI on PRs being processed by the merge queue.

This stack of pull requests is managed by Graphite. Learn more about stacking.

@codecov
Copy link

codecov bot commented Jun 18, 2025

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 52.35%. Comparing base (3dbf9e1) to head (a1d8373).
Report is 2 commits behind head on main.

Additional details and impacted files
@@           Coverage Diff           @@
##             main    #7373   +/-   ##
=======================================
  Coverage   52.35%   52.35%           
=======================================
  Files         939      939           
  Lines       63161    63161           
  Branches     4214     4214           
=======================================
  Hits        33070    33070           
  Misses      29984    29984           
  Partials      107      107           
Flag Coverage Δ
packages 52.35% <ø> (ø)
🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@iuwqyir iuwqyir requested a review from MananTank June 18, 2025 20:32
@iuwqyir iuwqyir marked this pull request as ready for review June 18, 2025 20:32
@iuwqyir iuwqyir requested review from a team as code owners June 18, 2025 20:32
@github-actions
Copy link
Contributor

github-actions bot commented Jun 18, 2025

size-limit report 📦

Path Size Loading time (3g) Running time (snapdragon) Total time
thirdweb (esm) 62.49 KB (0%) 1.3 s (0%) 575 ms (+271.07% 🔺) 1.9 s
thirdweb (cjs) 350.88 KB (0%) 7.1 s (0%) 1.5 s (+17.98% 🔺) 8.5 s
thirdweb (minimal + tree-shaking) 5.7 KB (0%) 114 ms (0%) 307 ms (+1949.16% 🔺) 421 ms
thirdweb/chains (tree-shaking) 531 B (0%) 11 ms (0%) 106 ms (+3484.1% 🔺) 116 ms
thirdweb/react (minimal + tree-shaking) 19.59 KB (0%) 392 ms (0%) 395 ms (+1580.38% 🔺) 787 ms

Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 1

📜 Review details

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

📥 Commits

Reviewing files that changed from the base of the PR and between 3dbf9e1 and 7871e40.

📒 Files selected for processing (1)
  • apps/playground-web/src/app/insight/[blueprint_slug]/blueprint-playground.client.tsx (1 hunks)
⏰ Context from checks skipped due to timeout of 90000ms (2)
  • GitHub Check: Size
  • GitHub Check: Analyze (javascript)

Comment on lines +818 to +824
const arraySchema = isRequired
? z.array(itemSchema).min(1, { message: "Required" })
: z.array(itemSchema).optional();
: z.array(itemSchema);
const arrayOrSingleItemSchema = z.union([arraySchema, itemSchema]);
return isRequired
? arrayOrSingleItemSchema
: arrayOrSingleItemSchema.optional();
Copy link
Contributor

Choose a reason for hiding this comment

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

⚠️ Potential issue

Fix validation inconsistency for required array parameters.

The union schema approach correctly solves the issue of accepting both single values and arrays. However, there's a validation inconsistency:

  • Required arrays validate with .min(1, { message: "Required" })
  • Required single items use the base itemSchema without additional validation
  • Other required parameter types in this function apply .min(1) validation (see lines 786-788, 795-797, 834-836)

This means a single empty string would pass validation while an empty array would fail.

Apply this fix to ensure consistent validation:

        if (itemSchema) {
+         let validatedItemSchema = itemSchema;
+         if (isRequired) {
+           if (schema.items.type === "string") {
+             validatedItemSchema = itemSchema.min(1, { message: "Required" });
+           } else if (schema.items.type === "number" || schema.items.type === "integer") {
+             validatedItemSchema = itemSchema.min(1, { message: "Required" });
+           }
+         }
+
          const arraySchema = isRequired
-           ? z.array(itemSchema).min(1, { message: "Required" })
-           : z.array(itemSchema);
-         const arrayOrSingleItemSchema = z.union([arraySchema, itemSchema]);
+           ? z.array(validatedItemSchema).min(1, { message: "Required" })
+           : z.array(itemSchema);
+         const arrayOrSingleItemSchema = z.union([arraySchema, validatedItemSchema]);
          return isRequired
            ? arrayOrSingleItemSchema
            : arrayOrSingleItemSchema.optional();
        }
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
const arraySchema = isRequired
? z.array(itemSchema).min(1, { message: "Required" })
: z.array(itemSchema).optional();
: z.array(itemSchema);
const arrayOrSingleItemSchema = z.union([arraySchema, itemSchema]);
return isRequired
? arrayOrSingleItemSchema
: arrayOrSingleItemSchema.optional();
if (itemSchema) {
let validatedItemSchema = itemSchema;
if (isRequired) {
if (schema.items.type === "string") {
validatedItemSchema = itemSchema.min(1, { message: "Required" });
} else if (schema.items.type === "number" || schema.items.type === "integer") {
validatedItemSchema = itemSchema.min(1, { message: "Required" });
}
}
const arraySchema = isRequired
? z.array(validatedItemSchema).min(1, { message: "Required" })
: z.array(itemSchema);
const arrayOrSingleItemSchema = z.union([arraySchema, validatedItemSchema]);
return isRequired
? arrayOrSingleItemSchema
: arrayOrSingleItemSchema.optional();
}
🤖 Prompt for AI Agents
In
apps/playground-web/src/app/insight/[blueprint_slug]/blueprint-playground.client.tsx
around lines 818 to 824, the validation for required single items lacks a
minimum length check, causing inconsistency with required arrays that enforce a
minimum of one item. To fix this, apply a `.min(1, { message: "Required" })`
validation to the single item schema within the union when isRequired is true,
ensuring both single items and arrays enforce the same minimum presence
requirement.

@iuwqyir iuwqyir added the merge-queue Adds the pull request to Graphite's merge queue. label Jun 18, 2025 — with Graphite App
Copy link
Contributor Author

iuwqyir commented Jun 18, 2025

Merge activity

  • Jun 18, 9:21 PM UTC: The merge label 'merge-queue' was detected. This PR will be added to the Graphite merge queue once it meets the requirements.
  • Jun 18, 9:21 PM UTC: iuwqyir added this pull request to the Graphite merge queue.

Fixes validation for query params that can be single or multiple value.
E.g. `?contract_address=0x...&contract_address=0x..`  and `?contract_address=0x..` are both valid queries. Doing just 1 value as in the second variant did not pass validation previously, but now does

<!-- start pr-codex -->

---

## PR-Codex overview
This PR modifies the schema validation logic in the `blueprint-playground.client.tsx` file to handle required and optional array or single item schemas more effectively.

### Detailed summary
- Updated the return value to use `arrayOrSingleItemSchema` for both required and optional cases.
- Introduced `arraySchema` to define the structure of required arrays.
- Created `arrayOrSingleItemSchema` to combine array and single item schemas.

> ✨ Ask PR-Codex anything about this PR by commenting with `/codex {your question}`

<!-- end pr-codex -->

<!-- This is an auto-generated comment: release notes by coderabbit.ai -->

## Summary by CodeRabbit

- **New Features**
  - Enhanced form input flexibility to accept either a single item or an array of items for array-typed parameters.

<!-- end of auto-generated comment: release notes by coderabbit.ai -->
@graphite-app graphite-app bot force-pushed the 06-18-insight_playground_-_allow_array_items_to_be_single_item branch from 7871e40 to a1d8373 Compare June 18, 2025 21:21
@vercel vercel bot temporarily deployed to Preview – login June 18, 2025 21:21 Inactive
@vercel vercel bot temporarily deployed to Preview – wallet-ui June 18, 2025 21:21 Inactive
@vercel vercel bot temporarily deployed to Preview – thirdweb-www June 18, 2025 21:21 Inactive
@vercel vercel bot temporarily deployed to Preview – nebula June 18, 2025 21:21 Inactive
@vercel vercel bot temporarily deployed to Preview – docs-v2 June 18, 2025 21:21 Inactive
@jnsdls jnsdls merged commit 381e423 into main Jun 18, 2025
22 checks passed
@jnsdls jnsdls deleted the 06-18-insight_playground_-_allow_array_items_to_be_single_item branch June 18, 2025 22:14
@graphite-app graphite-app bot removed the merge-queue Adds the pull request to Graphite's merge queue. label Jun 18, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Playground Changes involving the Playground codebase.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants