-
Notifications
You must be signed in to change notification settings - Fork 1
fix: reject non-alphanumeric SN codes in POST /v1/devices #10
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
base: main
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -1384,7 +1384,8 @@ | |
| "schema": { | ||
| "type": "string", | ||
| "minLength": 1, | ||
| "maxLength": 256 | ||
| "maxLength": 256, | ||
| "pattern": "^[a-zA-Z0-9_-]+$" | ||
| }, | ||
| "description": "Device serial number", | ||
| "example": "SFVA78RABZ12345678" | ||
|
|
@@ -7308,6 +7309,7 @@ | |
| "sn": { | ||
| "type": "string", | ||
| "nullable": true, | ||
| "pattern": "^[a-zA-Z0-9_-]+$", | ||
| "description": "Serial number of the device." | ||
|
Comment on lines
7310
to
7313
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. SN length constraints are inconsistent between body and path validation.
💡 Proposed fix"sn": {
"type": "string",
"nullable": true,
+ "maxLength": 256,
"pattern": "^[a-zA-Z0-9_-]+$",
"description": "Serial number of the device."
}"sn": {
"type": "string",
+ "maxLength": 256,
"pattern": "^[a-zA-Z0-9_-]+$",
"description": "Serial number of the device. This field is required when creating a device."
}"sn": {
"type": "string",
"nullable": true,
+ "maxLength": 256,
"pattern": "^[a-zA-Z0-9_-]+$"
}Also applies to: 7450-7453, 7473-7477 🤖 Prompt for AI Agents |
||
| }, | ||
| "display_name": { | ||
|
|
@@ -7447,6 +7449,7 @@ | |
| }, | ||
| "sn": { | ||
| "type": "string", | ||
| "pattern": "^[a-zA-Z0-9_-]+$", | ||
| "description": "Serial number of the device. This field is required when creating a device." | ||
| } | ||
| } | ||
|
|
@@ -7469,7 +7472,8 @@ | |
| }, | ||
| "sn": { | ||
| "type": "string", | ||
| "nullable": true | ||
| "nullable": true, | ||
| "pattern": "^[a-zA-Z0-9_-]+$" | ||
| }, | ||
| "display_name": { | ||
| "type": "string", | ||
|
|
@@ -7500,6 +7504,7 @@ | |
| "properties": { | ||
| "sn": { | ||
| "type": "string", | ||
| "pattern": "^[a-zA-Z0-9_-]+$", | ||
| "description": "Device serial number", | ||
| "example": "SFVA78RABZ12345678" | ||
| }, | ||
|
|
||
| Original file line number | Diff line number | Diff line change | ||||||||
|---|---|---|---|---|---|---|---|---|---|---|
|
|
@@ -1044,6 +1044,7 @@ paths: | |||||||||
| type: string | ||||||||||
| minLength: 1 | ||||||||||
| maxLength: 256 | ||||||||||
| pattern: ^[a-zA-Z0-9_-]+$ | ||||||||||
| description: Device serial number | ||||||||||
| example: SFVA78RABZ12345678 | ||||||||||
| get: | ||||||||||
|
|
@@ -5776,6 +5777,7 @@ components: | |||||||||
| sn: | ||||||||||
| type: string | ||||||||||
| nullable: true | ||||||||||
|
||||||||||
| nullable: true | |
| nullable: true | |
| minLength: 1 | |
| maxLength: 256 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
In JSON, the
/v1/devices/sn/{sn}parameter enforcesmaxLength: 256, but thesnfields in request-body schemas (e.g.,DeviceProperties/DeviceInput/DeviceUpdate) still lackminLength/maxLength. That means POST/PATCH can accept very long SN strings that can’t be used with the SN lookup endpoint and may increase validation/payload costs. Align thesnlength constraints across schemas (e.g., minLength 1, maxLength 256).