8000 Hold uploaded data files to the same consistency checks as yarn validate by noahm · Pull Request #679 · noahm/DDRCardDraw · GitHub
[go: up one dir, main page]

Skip to content

Hold uploaded data files to the same consistency checks as yarn validate - #679

Merged
noahm merged 1 commit into
partykitfrom
upload-consistency-checks
Oct 23, 2026
Merged

noahm merged 1 commit into
partykitfrom
upload-consistency-checks

Conversation

@noahm
@noahm noahm commented Oct 23, 2026
Copy link
Copy Markdown
Owner

Follow-up to #678. A premade .json file uploaded through the custom-data dialog was only checked against the schema. It now also gets the consistency checks yarn validate runs on bundled data:

  • every declared style, difficulty and flag has an en translation, and difficulties also have an $abbr one
  • the default style and difficulties exist
  • the default level bounds aren't reversed
  • charts use known styles and diffClass values
  • folders are listed
  • draw groups are present when usesDrawGroups is set
  • chart ids are unique within the file

How

  • Shared module: the checks moved out of scripts/validate.mjs into src/utils/game-data-consistency.ts, with the same logic and messages, so the script and the app can't drift apart. The module has only type imports, so the script loads it directly through Node 24's type stripping.
  • Jacket files: the script passes in its own check for jacket files, since that needs the filesystem. The browser skips it.
  • Node warning: importing a .ts file from the script makes Node print a "Reparsing as ES module" warning, because package.json has no "type". validate:types:data now runs with --disable-warning=MODULE_TYPELESS_PACKAGE_JSON. Switching to .mts would have needed webpack and import-path changes.
  • In the form: the upload form runs these checks after the schema check passes. It shows up to 8 problems, then "…and N more", and keeps Publish disabled.
  • Not in the loader: loadCustomGamedataByUrl doesn't run these checks, so a bundle that's already published can't become unloadable.

Not covered

The data.ddr.tools Worker still only validates against the schema, so a file published straight to the API without the app skips these checks.

Testing

  • yarn validate:types:data passes on all stock data, and the regenerated SongData.ts is unchanged.
  • Types and lint are clean.
  • In the browser, a copy of shine-2026.json with three mistakes listed all four problems in the dialog, and Publish stayed disabled. The mistakes:
    • a missing challenge translation (which counts for both the full and the $abbr one)
    • an untranslated flag
    • an unknown chart style
  • The unmodified file reports no problems.

🤖 Generated with Claude Code

Moves validate.mjs's consistency checks (declared styles, difficulties
and flags all translated, defaults that exist, known styles/diffClasses
on charts, draw groups, folders, unique chart ids) into a shared
src/utils/game-data-consistency.ts. The script imports it directly via
Node's type stripping and passes in its jacket-file check; the premade
JSON upload form runs the rest after the schema passes.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@vercel
vercel Bot commented Oct 23, 2026 •
Copy link
Copy Markdown

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

Project Deployment Actions Updated
ddr-tools Ready Ready Preview Oct 23, 2026 6:11pm UTC

@noahm
noahm merged commit 938444c into partykit Oct 23, 2026
7 checks passed
@noahm
noahm deleted the upload-consistency-checks branch October 23, 2026 18:15
noahm added a commit that referenced this pull request Oct 26, 2026
Resolves conflicts with #678 and #679:
- validate.mjs now delegates to the shared findConsistencyErrors, so the
  duplicate song id check moves into src/utils/game-data-consistency.ts.
- loadCustomGamedataByUrl validates against the schema a bundle declares.
  Hosted v1 forbids `song.id`, so a bundle declaring a hosted schema is
  validated as published and upgraded afterwards; one held to the bundled
  v2 schema is upgraded first, as before.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

This branch was successfully deployed

1 active deployment
Preview — dc88b01c Deployed Oct 23, 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

0