-
Notifications
You must be signed in to change notification settings - Fork 42
[codex] Validate affiliate offer tag types #419
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
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 |
|---|---|---|
|
|
@@ -121,8 +121,17 @@ export function validateOfferInput(input: OfferInput): ValidationResult { | |
| errors.push(`Category must be one of: ${SKILL_CATEGORIES.join(", ")}`); | ||
| } | ||
|
|
||
| if (input.tags && input.tags.length > 10) { | ||
| errors.push("Maximum 10 tags"); | ||
| if (input.tags !== undefined) { | ||
| if (!Array.isArray(input.tags)) { | ||
| errors.push("tags must be an array"); | ||
| } else { | ||
| if (input.tags.length > 10) { | ||
| errors.push("Maximum 10 tags"); | ||
| } | ||
| if (input.tags.some((tag) => typeof tag !== "string")) { | ||
| errors.push("tags must be strings"); | ||
| } | ||
| } | ||
| } | ||
|
Comment on lines
+124
to
135
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.
The guard changed from |
||
|
|
||
| if (errors.length > 0) { | ||
|
|
||
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.
tagsvalueThe PR description says "reject non-array
tagsvalues," but the only new test uses an array that contains a non-string element (["valid", 123]). There is no test for the fully non-array case (e.g.,tags: "string",tags: 42, ortags: null), leaving the new!Array.isArray(input.tags)branch untested. A test fortags: "not-an-array"would directly exercise the new guard and would also surface thenullbehavior described in the companion comment.