Skip to content

Follow-up: enforce positive whole page values in Collection pagination#838

Closed
chadwickmeyer wants to merge 3 commits into
masterfrom
codex/github-mention-update-@stratusjs/angularjs-package-to-v0.11
Closed

Follow-up: enforce positive whole page values in Collection pagination#838
chadwickmeyer wants to merge 3 commits into
masterfrom
codex/github-mention-update-@stratusjs/angularjs-package-to-v0.11

Conversation

@chadwickmeyer

Copy link
Copy Markdown
Contributor

Motivation

  • Prevent invalid page values from user-controlled query parameters (e.g. -1, 1.5, Infinity, NaN) being forwarded to the API via api.p and causing incorrect pagination.
  • Centralize page-number validation so all pagination entry points behave consistently and defensively.

Description

  • Added a private helper normalizePositiveWholeNumber() that returns a finite integer >= 1 or undefined for invalid inputs.
  • In sync() added defensive handling for data.p so p is normalized and removed when invalid before serializing the request.
  • Updated page(page) to validate the incoming page value, short-circuit on invalid input, and only set meta.api.p when the value is a valid whole positive number.

Testing

  • Ran git diff --check to validate there are no whitespace/patch issues and it passed.
  • Inspected the changes with git diff to verify the intended edits to packages/angularjs/src/services/collection.ts were applied as expected.

Codex Task

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 743bf17bf4

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

const validPage = this.normalizePositiveWholeNumber(page)
this.paginate = !isUndefined(validPage)
if (isUndefined(validPage)) {
delete this.meta.get('api').p

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P1 Badge Guard api metadata before deleting page on invalid input

In page(), the invalid-input branch calls delete this.meta.get('api').p before any code ensures meta.api exists. For a fresh Collection where no api metadata has been set yet, this.meta.get('api') is undefined, so this throws at runtime instead of safely ignoring the bad page value; this means malformed page params can now crash pagination flow rather than being handled defensively.

Useful? React with 👍 / 👎.

@chadwickmeyer chadwickmeyer deleted the codex/github-mention-update-@stratusjs/angularjs-package-to-v0.11 branch April 30, 2026 14:11
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant