Skip to content

lua: shared list cursor, IN and sort helpers; reject year-0000 cursors - #91

Merged
Kzoeps merged 6 commits into
mainfrom
lua/shared-list-helpers
Nov 18, 2026
Merged

Kzoeps merged 6 commits into
mainfrom
lua/shared-list-helpers

Conversation

@Kzoeps

@Kzoeps Kzoeps commented Nov 18, 2026

Copy link
Copy Markdown
Collaborator

Stacked on #90.

Problem

List endpoints carry copied cursor decoding, created_at sort SQL and IN (...) loops. A cursor with a year-0000 timestamp reached PostgreSQL on many endpoints and returned an HTTP 500.

Fix

  • valid_datetime rejects year 0000, so these cursors now return InvalidRequest. Per-endpoint year checks are removed. listVocabTags now reports this case as "cursor is malformed".
  • New shared helpers: decode_cursor (listCursor.lua, one validate callback), add_in (listWhere.lua, empty list gives FALSE) and created_at_sort(alias) (createdAtSort.lua).
  • Moved listRights, listMeasurements, listContributorInformation, listContributions, listAcknowledgements and listWorkscopeTags onto them. The SQL golden from tests: add list endpoint SQL golden safety net #90 is unchanged apart from the year-0000 cases.
  • listContributions keeps its own sort SQL with the unused 'epoch' fallback; unifying it would change SQL text, so it is left for a separate change.

@vercel

vercel Bot commented Nov 18, 2026 •

Copy link
Copy Markdown

The latest updates on your projects. Learn more about Vercel for GitHub.

1 Skipped Deployment
Project Deployment Actions Updated
api-endpoints Skipped Skipped Nov 18, 2026 3:37pm UTC

Request Review

@changeset-bot

changeset-bot Bot commented Nov 18, 2026 •

Copy link
Copy Markdown

🦋 Changeset detected

Latest commit: f14d46c

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 1 package
Name Type
@hypercerts-org/happyview-modules Patch

Not sure what this means? Click here to learn what changesets are.

Click here if you're a maintainer who wants to add another changeset to this PR

@coderabbitai

coderabbitai Bot commented Nov 18, 2026 •

Copy link
Copy Markdown

Warning

Review limit reached

You've used all free OSS reviews for now. Wait for the free limit to reset to keep reviewing this public repository.

Next included review available in 4 seconds.

Check out review usage here.

View limit details

Limit details: You’ve used the included review currently available.

Learn how review limits work.

Review configuration:

Run configuration

  • Source mode: Auto
  • Repository: Unavailable
  • Branch: Unavailable
  • File: No configuration file from this repository applied
  • Commit: Unavailable
  • Layers: defaults
  • Review profile: CHILL
  • Plan: Advanced
  • Run ID: 6fbdf701-4fed-4e50-bc6b-0ce7f6a5aea0
Commits

Reviewing files that changed from the base of the PR and between c634d7b and f14d46c.

Files selected for processing: 62

  • .changeset/reject-year-zero-cursor.md
  • happyview-modules/lua/endpoints/getActorLikes.lua
  • happyview-modules/lua/endpoints/getActorReposts.lua
  • happyview-modules/lua/endpoints/getLikes.lua
  • happyview-modules/lua/endpoints/getReposts.lua
  • happyview-modules/lua/endpoints/listAcknowledgements.lua
  • happyview-modules/lua/endpoints/listActivities.lua
  • happyview-modules/lua/endpoints/listActorFollowers.lua
  • happyview-modules/lua/endpoints/listActorFollowing.lua
  • happyview-modules/lua/endpoints/listAttachments.lua
  • happyview-modules/lua/endpoints/listBadgeAwards.lua
  • happyview-modules/lua/endpoints/listBadgeDefinitions.lua
  • happyview-modules/lua/endpoints/listBadgeResponses.lua
  • happyview-modules/lua/endpoints/listCollections.lua
  • happyview-modules/lua/endpoints/listContributions.lua
  • happyview-modules/lua/endpoints/listContributorInformation.lua
  • happyview-modules/lua/endpoints/listEntityFollowers.lua
  • happyview-modules/lua/endpoints/listEntityFollowing.lua
  • happyview-modules/lua/endpoints/listEvaluations.lua
  • happyview-modules/lua/endpoints/listEvmLinks.lua
  • happyview-modules/lua/endpoints/listFeatures.lua
  • happyview-modules/lua/endpoints/listLocations.lua
  • happyview-modules/lua/endpoints/listMeasurements.lua
  • happyview-modules/lua/endpoints/listOrganizations.lua
  • happyview-modules/lua/endpoints/listProfiles.lua
  • happyview-modules/lua/endpoints/listReceipts.lua
  • happyview-modules/lua/endpoints/listRecentFollows.lua
  • happyview-modules/lua/endpoints/listRights.lua
  • happyview-modules/lua/endpoints/listVocabTags.lua
  • happyview-modules/lua/endpoints/listWorkscopeTags.lua
  • happyview-modules/lua/endpoints/searchActivities.lua
  • happyview-modules/lua/endpoints/searchBadgeDefinitions.lua
  • happyview-modules/lua/endpoints/searchCollections.lua
  • happyview-modules/lua/endpoints/searchOrganizations.lua
  • happyview-modules/lua/endpoints/searchProfiles.lua
  • happyview-modules/lua/shared/acknowledgementList.lua
  • happyview-modules/lua/shared/activityList.lua
  • happyview-modules/lua/shared/collectionList.lua
  • happyview-modules/lua/shared/createdAtSort.lua
  • happyview-modules/lua/shared/datetimeValidation.lua
  • happyview-modules/lua/shared/listCursor.lua
  • happyview-modules/lua/shared/listWhere.lua
  • happyview-modules/lua/shared/organizationList.lua
  • happyview-modules/lua/shared/profileList.lua
  • happyview-modules/lua/shared/workscopeTagList.lua
  • happyview-modules/lua/src/listContributions.lua
  • happyview-modules/lua/src/listContributorInformation.lua
  • happyview-modules/lua/src/listFeatures.lua
  • happyview-modules/lua/src/listMeasurements.lua
  • happyview-modules/lua/src/listRights.lua
  • happyview-modules/lua/src/listVocabTags.lua
  • happyview-modules/modules/acknowledgements/manifest.json
  • happyview-modules/modules/context-measurements/manifest.json
  • happyview-modules/modules/contribution/manifest.json
  • happyview-modules/modules/contributor-information/manifest.json
  • happyview-modules/modules/rights/manifest.json
  • happyview-modules/modules/workscope-tags/manifest.json
  • happyview-modules/tests/unit/endpoints/rights-edge-lua.test.js
  • happyview-modules/tests/unit/endpoints/rights-lua.test.js
  • happyview-modules/tests/unit/list-golden/list-endpoints.golden.jsonl
  • happyview-modules/tests/unit/tooling/listContributorInformation.test.js
  • happyview-modules/tests/unit/tooling/vocab-tags.test.js
  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

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

A crafted year-0000 cursor reached SQL on 51 golden cases and returned a 500.
listVocabTags keeps its now-unreachable year check; its error text for this case
changes to the generic cursor message.
…x list endpoints

listRights, listMeasurements, listContributorInformation, listContributions,
listAcknowledgements and listWorkscopeTags use the shared cursor decoder and IN
helper; acknowledgement also takes parse_sort_direction and cursor_encode from
listQuery. created_at_sort(alias) replaces the closed four-source table and the
rights/measurement/contributor copies. listContributions keeps its own sort key
(its COALESCE has an extra 'epoch' fallback). Golden unchanged.
@Kzoeps
Kzoeps force-pushed the lua/shared-list-helpers branch from 112ddac to 79d7002 Compare November 18, 2026 15:04
Base automatically changed from lua/list-golden-safety-net to main November 18, 2026 15:37
@sonarqubecloud

Copy link
Copy Markdown

❌ The last analysis has failed.

See analysis details on SonarQube Cloud

@Kzoeps
Kzoeps merged commit 65f4bc8 into main Nov 18, 2026
7 of 8 checks passed
@Kzoeps
Kzoeps deleted the lua/shared-list-helpers branch November 18, 2026 15:41

This branch was previously deployed

1 inactive deployment
Preview — f14d46cc Deployed Nov 18, 2026 by vercel[bot]
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.

1 participant