Skip to content

stop nan values in params showing as a problem instead invalid params#1237

Open
pooleycodes wants to merge 3 commits into
mainfrom
1236-valierror-invalid-type-expected-number-but-received-nan
Open

stop nan values in params showing as a problem instead invalid params#1237
pooleycodes wants to merge 3 commits into
mainfrom
1236-valierror-invalid-type-expected-number-but-received-nan

Conversation

@pooleycodes

@pooleycodes pooleycodes commented Jul 23, 2026

Copy link
Copy Markdown
Contributor

What type of PR is this? (check all applicable)

  • Refactor
  • Feature
  • Bug Fix
  • Optimization
  • Documentation Update

Description

A valibot parsing on page number values meant that letters values would be converted to NaN, which would then fail at the v.minValue() stage in the pipeline(), v.number() stops these NaN values getting through.

This resolves the attached Sentry Issue

Related Tickets & Documents

QA Instructions, Screenshots, Recordings

Please replace this line with instructions on how to test your changes, a note
on the devices and browsers this has been tested on, as well as any relevant
images for UI changes.

For URL such as /organisations/local-authority:BUC/conservation-area/data/avc used to get:

image

Will now get:

image

Added/updated tests?

We encourage you to keep the code coverage percentage at 80% and above. Please refer to the Digital Land Testing Guidance for more information.

  • Yes
  • No, and this is why: please replace this line with details on why tests
    have not been included
  • I need help with writing tests

[optional] Are there any post deployment tasks we need to perform?

No

[optional] Are there any dependencies on other PRs or Work?

No

Summary by CodeRabbit

  • Bug Fixes
    • Improved pagination parameter validation across issue details, results, data views and failed-expectation views.
    • Page numbers are now parsed consistently using base-10 conversion.
    • Invalid, non-integer and zero or negative page numbers are rejected more reliably.

@pooleycodes pooleycodes linked an issue Jul 23, 2026 that may be closed by this pull request
@coderabbitai

coderabbitai Bot commented Jul 23, 2026

Copy link
Copy Markdown
Contributor

Review Change Stack

Walkthrough

Page-number validation now parses query strings with an explicit base-10 radix and enforces numeric integer values with a minimum of 1 across issue-details, results, dataset-failed-expectation, and dataview request paths.

Changes

Pagination validation

Layer / File(s) Summary
Tighten page-number schemas
src/controllers/issueDetailsController.js, src/controllers/resultsController.js, src/middleware/*
Page-number pipelines use explicit base-10 parsing and enforce numeric integer values before the existing minimum-value validation; optional defaults remain unchanged.

Estimated code review effort: 2 (Simple) | ~5 minutes

Possibly related PRs

Suggested labels: bug

Suggested reviewers: dilwoarh

Poem

I’m a rabbit with pages to turn,
Base ten makes the numbers burn.
Integers stand in a tidy line,
Minimum one keeps the count just fine.
Hop, hop—validation shines!

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title matches the main change: it aims to make NaN parameter values be treated as invalid parameters rather than a problem.
✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch 1236-valierror-invalid-type-expected-number-but-received-nan

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.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@github-actions

github-actions Bot commented Jul 23, 2026

Copy link
Copy Markdown

Coverage Report

Status Category Percentage Covered / Total
🔵 Lines 71.16% 2559 / 3596
🔵 Statements 70.37% 2701 / 3838
🔵 Functions 64.48% 512 / 794
🔵 Branches 64.26% 1268 / 1973
File Coverage
File Stmts Branches Functions Lines Uncovered Lines
Changed Files
src/controllers/issueDetailsController.js 38% 50% 7.69% 40.42% 14, 34, 51, 64-76, 80, 86-108, 114-147
src/controllers/resultsController.js 45.14% 41.07% 44.68% 46.22% 21-39, 58-64, 78-99, 108-111, 116, 154-155, 188-195, 207, 233-246, 258, 269, 274-286, 295-304, 316, 401-402, 419-449, 457-503, 514-524, 558-585
src/middleware/dataview.middleware.js 88.09% 65.51% 54.54% 87.8% 44, 106, 111, 131-153
src/middleware/entryIssueDetails.middleware.js 71.42% 65.51% 54.54% 70.73% 12, 21-24, 47-56, 82-84, 125-129
Generated in workflow #1565 for commit 5daf848 by the Vitest Coverage Report Action

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Actionable comments posted: 1

🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In `@src/controllers/issueDetailsController.js`:
- Line 14: Replace the parseInt-first page-number validation with strict
complete decimal-integer validation before conversion, rejecting NaN, decimals,
and trailing text while preserving the minimum value of 1 and default of 1.
Apply the same schema change at issue-details pagination, results pagination,
expectation pagination, dataview pagination, and entry issue-details pagination:
src/controllers/issueDetailsController.js#L14-L14,
src/controllers/resultsController.js#L558-L558,
src/middleware/dataset-failed-expectation-entry.middleware.js#L44-L44,
src/middleware/dataview.middleware.js#L35-L35, and
src/middleware/entryIssueDetails.middleware.js#L12-L12. Add coverage for NaN,
decimal, and trailing-text inputs.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Repository UI

Review profile: CHILL

Plan: Pro Plus

Run ID: 84760ac4-deff-4bec-af8d-aad7eca616fd

📥 Commits

Reviewing files that changed from the base of the PR and between 9becdbd and aa881b0.

📒 Files selected for processing (5)
  • src/controllers/issueDetailsController.js
  • src/controllers/resultsController.js
  • src/middleware/dataset-failed-expectation-entry.middleware.js
  • src/middleware/dataview.middleware.js
  • src/middleware/entryIssueDetails.middleware.js

Comment thread src/controllers/issueDetailsController.js
@pooleycodes
pooleycodes deployed to development July 23, 2026 13:48 — with GitHub Actions Active

@gibahjoe gibahjoe left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

LGTM

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

ValiError: Invalid type: Expected number but received NaN

2 participants