fix: validate price_id format to reject invalid characters#11
fix: validate price_id format to reject invalid characters#11Washio20 wants to merge 1 commit intostayforge:mainfrom
Conversation
|
Note Reviews pausedIt looks like this branch is under active development. To avoid overwhelming you with review comments due to an influx of new commits, CodeRabbit has automatically paused this review. You can configure this behavior by changing the Use the following commands to manage reviews:
Use the checkboxes below for quick actions:
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review infoConfiguration used: Organization UI Review profile: CHILL Plan: Pro 📒 Files selected for processing (2)
🚧 Files skipped from review as they are similar to previous changes (2)
📝 WalkthroughWalkthroughAdded regex validation Changes
Estimated code review effort🎯 2 (Simple) | ⏱️ ~10 minutes Poem
🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches🧪 Generate unit tests (beta)
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. Comment |
There was a problem hiding this comment.
Pull request overview
This pull request adds regex pattern validation to the price_id field in the OpenAPI specification to enforce Stripe-compatible pricing ID formats. The change addresses issue #4, which reported that the API was accepting invalid characters (e.g., Chinese characters) in the price_id field, potentially causing billing issues.
Changes:
- Added
pattern: ^[a-zA-Z0-9_-]+$validation toprice_idfields in bothDevicePropertiesandDeviceUpdateschemas - Applied changes consistently to both
openapi.yamlandopenapi.jsonfiles
Reviewed changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated 2 comments.
| File | Description |
|---|---|
| openapi.yaml | Added regex pattern validation to price_id in DeviceProperties schema (line 5789) and DeviceUpdate schema (line 5974) to restrict input to alphanumeric characters, underscores, and hyphens |
| openapi.json | Added regex pattern validation to price_id in DeviceProperties schema (line 7323) and DeviceUpdate schema (line 7484), matching the YAML changes |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| type: string | ||
| nullable: true | ||
| pattern: ^[a-zA-Z0-9_-]+$ | ||
| description: Stripe price ID for billing purposes. |
There was a problem hiding this comment.
Consider updating the description to document the validation pattern, similar to how device_id documents its format constraints. For example: "Stripe price ID for billing purposes. Must contain only alphanumeric characters, underscores, or hyphens." This would help API consumers understand the validation requirements without needing to inspect the schema.
| description: Stripe price ID for billing purposes. | |
| description: Stripe price ID for billing purposes. Must contain only alphanumeric characters, underscores (_), or hyphens (-). |
| "type": "string", | ||
| "nullable": true, | ||
| "pattern": "^[a-zA-Z0-9_-]+$", | ||
| "description": "Stripe price ID for billing purposes." |
There was a problem hiding this comment.
Consider updating the description to document the validation pattern, similar to how device_id documents its format constraints. For example: "Stripe price ID for billing purposes. Must contain only alphanumeric characters, underscores, or hyphens." This would help API consumers understand the validation requirements without needing to inspect the schema.
| "description": "Stripe price ID for billing purposes." | |
| "description": "Stripe price ID for billing purposes.\nMust contain only alphanumeric characters, underscores (_), or hyphens (-).\n" |
…ayforge#4) Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Summary
pattern: ^[a-zA-Z0-9_-]+$regex validation to allprice_idfields in the OpenAPI specRoot Cause
The
price_idfield in the device schemas (DeviceProperties, DeviceUpdate) had no format validation, allowing any string including non-alphanumeric characters to be submitted. Stripe pricing IDs only contain alphanumeric characters, hyphens, and underscores.Changes
openapi.yaml: Addedpattern: ^[a-zA-Z0-9_-]+$toprice_idfields in DeviceProperties and DeviceUpdate schemasopenapi.json: Same pattern added to the corresponding JSON definitionsTesting
^[a-zA-Z0-9_-]+$correctly:price_1234,price-abc,priceABC123Closes #4
Summary by CodeRabbit