Skip to content

fix: repair test and contract files that were committed as base64 - #376

Merged
github-actions[bot] merged 4 commits into
TRELLIS-STELLAR:mainfrom
OkeyAmy:chore/restore-test-tooling
Oct 18, 2026
Merged

github-actions[bot] merged 4 commits into
TRELLIS-STELLAR:mainfrom
OkeyAmy:chore/restore-test-tooling

Conversation

@OkeyAmy

@OkeyAmy OkeyAmy commented Oct 18, 2026

Copy link
Copy Markdown
Contributor

Scope

Three files on main are broken: two are not source code at all, and they get in the way of every contributor's test run. Each one is repaired here.

  1. src/common/guard/quota.guard.spec.ts landed in f6c09b5 as one 26,295-character base64 line, which makes Jest abort the suite with a parse error. The last readable revision is restored, then extended — monthly quota behavior had zero coverage before this. The guard's redis counter is driven by a mocked client: one increment per request, a paid tier limit of 1,000,000 (not the 10,000 free-tier fallback), 429 QUOTA_EXCEEDED once the allowance runs out, and unlimited for enterprise while redis stays untouched.

  2. scripts/validate-openapi.ts became a base64 line in fee9663, and decoding it reveals damage that the encoding alone did not cause: the header reads function parseArgvv: {, a template literal is missing its closing backtick, curItem appears where the identifier is currItem, and the output stops in the middle of a console.log. The file is rebuilt from the decoded body with those four statements repaired; the generateOpenAPISpec and main sections are carried back over from fee9663~1, the last plain version, and the breaking-change checks introduced by fee9663 are kept.

  3. src/storage-compatibility/storage-schema-compatibility.ts spells out the glob **/migration/* inside a doc comment. The embedded */ terminates the comment early and leaves migration as a bare identifier, so ts-node aborts openapi:export and openapi:validate with TS2304: Cannot find name 'migration'. Escaping the slash keeps the text intact.

Alongside these

  • The redis package is added to package.json. quota.guard.ts imports it, yet nothing ever declared it, so any spec loading the guard died with Cannot find module 'redis'.
  • MONTHLY_QUOTA_LIMITS uses paid where it used pro, consistent with RateLimitTier = "free" | "paid" | "enterprise". Previously the paid tier matched no key and slipped into ?? MONTHLY_QUOTA_LIMITS.free, capping paying callers at 10,000 requests per month. A test now locks in the correct number.

The consequence of a base64 test file

While any file has a syntax error, tsc --noEmit emits syntactic diagnostics and never reaches semantic analysis. The blob produced exactly two errors, both in itself, and obscured roughly 295 genuine type errors spread across 80 files. Those remain — fixing them belongs elsewhere — but the blindfold is gone.

Checks

  • npx jest src/common/guard/quota.guard.spec.ts — 7 of 7 green
  • npx tsc --noEmit — clean for every file touched here; overall counts shift only by the two errors this resolves
  • npm run openapi:export now advances past storage-schema-compatibility and halts on the next missing module, notification-deduplication.service. One blocker cleared; the others are pre-existing.

Reverting

The commits are independent, one per set of files. Revert any of them and the tree returns to its previous state. There are no schema or runtime links, with redis as the only added dependency.

Stacked on #375 (jest.config.js payload removal). Until that merges, this diff includes its one commit as well; the reviewable slice for this PR is the three fix: commits on top.

Line 40 of jest.config.js carried ~26KB of minified/obfuscated JavaScript
appended after the legitimate config object. It contained eval() and a
detached child_process.spawn of a -e script, plus outbound fetch calls,
and executed every time Jest loaded its configuration.

Introduced in e4c92ad. This restores the file to the intended 40-line
config; no configuration values change.
src/common/guard/quota.guard.spec.ts was committed as a single base64
line (26k chars) in f6c09b5, so the suite failed to parse and the file
masked every other TypeScript error (tsc stops after syntax errors).

- restore the last plain revision of the spec and extend it with
  redis-backed monthly quota coverage (counter increments, paid limit,
  429 QUOTA_EXCEEDED, enterprise unlimited) using a mocked redis driver
- declare the redis package the guard imports; it was used but never a
  dependency, so any test importing quota.guard failed to resolve it
- rename the MONTHLY_QUOTA_LIMITS key pro -> paid to match the
  RateLimitTier union; paid requests previously fell back to the free
  10k limit via the ?? fallback in consumeMonthlyQuota
The script was committed as one base64 line in fee9663 and its decoded
content was damaged in several places (mangled function signature,
unterminated template literal, a comment-terminated expression, plus a
truncated tail). Rebuild it from the decoded body: repair the four
corrupted statements, re-derive the generateOpenAPISpec/main tail from
the last plain revision (fee9663~1), and keep the breaking-change
detection that fee9663 added. The file type-checks under ts-node again.
'any nested **/migration/* directory' contains the byte sequence */ in
the middle of a block comment, which closes it early; the word
'followed by migration' then parses as code and tsc fails with
TS2304: Cannot find name 'migration'. That error aborted every
ts-node boot path (openapi:export, openapi:validate). Escape the slash
so the glob stays readable.
@drips-wave

drips-wave Bot commented Oct 18, 2026

Copy link
Copy Markdown

Hey @OkeyAmy! 👋 It looks like this PR isn't linked to any issue.

If this PR is for one of the issues assigned to you as part of a Wave, please link it to ensure your contribution is tracked properly. You can do this by adding a keyword to the PR description (e.g., Closes #123), or by clicking a button below:

Issue Title
#214 Trellis API: Add high-cardinality telemetry protection with redaction and sampling rules Link to this issue
#220 Trellis API: Add maintainer action approval flow with signed intent receipts Link to this issue
#218 Trellis API: Build multi-actor concurrency harness for race-prone mutations Link to this issue

ℹ️ Learn more about linking PRs to issues

@github-actions

Copy link
Copy Markdown

Code Review & Auto-Merge — @dorismaduegbunam 🚀

Thank you @OkeyAmy for your contribution!

  • PR Title: fix: repair test and contract files that were committed as base64

  • Author: @OkeyAmy

  • Branch: chore/restore-test-tooling -> main

  • Status: Approved & Merged into main.

Verified code changes and repository requirements. Merging pull request.

@github-actions
github-actions Bot merged commit f94cdfe into TRELLIS-STELLAR:main Oct 18, 2026
1 of 3 checks passed
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