You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Upgrade @faker-js/faker past 10.2, where sexType() can return 'generic' #1620
Area: APIapps/api (NestJS backend, Prisma models, CASL permissions)ChoreType: maintenance with no user-visible change (dependency upgrades, tooling, tests, refactors)Difficulty: LowIsolated change, about 2 hours or lessGood First IssueWell-scoped, low-risk and self-contained; a good entry point for a new contributorPriority: LowNice to have, cosmetic or speculative
@faker-js/faker is held at ~10.2.0 in apps/api by the dependency update on the deps branch. The newest release eligible under the repo's 7-day minimumReleaseAge on 2026-10-04 was 10.6.0.
Why it was not upgraded
faker 10.3.0 adds Generic = "generic" to its Sex enum.
As a result, faker.person.sexType() is typed 'female' | 'male' | 'generic', even though it only returns 'generic' when passed { includeGeneric: true }.
The demo seeder upper-cases that value into a subject's sex:
The value then goes to generateSubjectHash (line 114) and subjectsService.create (line 122). Both expect $Sex = z.enum(['MALE', 'FEMALE']) from packages/schemas/src/subject/subject.ts:9, so tsc fails with two TS2345 errors.
What is required
Narrow the value in demo.service.ts, for example with faker.helpers.arrayElement(['MALE', 'FEMALE'] as const).
Bump @faker-js/faker back to a caret range.
Seeded demo values can differ between faker versions, so check that no test asserts on specific seeded data.
Fixed by open PR #1660 (commit c0d58b9), not merged yet. main (d86740e) still pins "@faker-js/faker": "~10.2.0" at apps/api/package.json:27.
Merging #1660 will not close this issue. Its body says Closes #1624, #1626, #1618, #1620, ..., but GitHub needs the keyword in front of each number, so #1624 is the only issue linked to the PR. Rewrite that line as Closes #1624, Closes #1626 and so on, or close this issue and the other 12 by hand after the merge.
It moves to ^10.6.0, which is still the latest release on npm. It seeds sex: faker.helpers.arrayElement($Sex.options) and drops the toUpperCase import, which nothing else uses. Use that rather than the literal ['MALE', 'FEMALE'] as const from the issue: the values come from $Sex, so the seeder can't drift from the schema. This is the only sexType() call in the repo.
The new unit test pins the seeded sexes to $Sex.options. It also passes on the current code, because sexType() without options never returns 'generic'. What actually catches this break is tsc.
Seeded data
No test asserts on specific seeded values. demo.service.test.ts checks that the id is the hash of the seeded fields (:145-150), the custom-id numbering (:152-165) and the rating ranges (:186-200). It never checks a name, a date or a sex. The e2e specs create their own subjects through the start-session form, for example testing/src/specs/datahub.spec.ts:66.
The change needs no new e2e spec. The global setup (testing/src/global/setup.spec.ts:15-22) seeds 10 subjects with 10 records each through DemoService.init (apps/api/src/setup/setup.service.ts:100-104), and both the chromium and firefox projects depend on it (testing/playwright.config.ts:26, :33).
Landing
#1660 conflicts with main. If it stalls, c0d58b9 cherry-picks onto main by itself without conflicts, pnpm-lock.yaml included. I checked this with a three-way merge of each file it touches. Run pnpm install afterwards to confirm the lockfile.
The Dependabot PRs #1631 (~10.5.0) and #1579 (^10.5.0) also move faker past 10.3 without touching demo.service.ts. Merging either one would bring back the two TS2345 errors, so neither faker bump should land ahead of this fix.
The Good First Issue label can come off, since the fix already exists.
Triage note written with Claude Code. Code references point at main @ d86740e.
Area: APIapps/api (NestJS backend, Prisma models, CASL permissions)ChoreType: maintenance with no user-visible change (dependency upgrades, tooling, tests, refactors)Difficulty: LowIsolated change, about 2 hours or lessGood First IssueWell-scoped, low-risk and self-contained; a good entry point for a new contributorPriority: LowNice to have, cosmetic or speculative
Activity
joshunrau commentedon Oct 26, 2026
Fixed by open PR #1660 (commit c0d58b9), not merged yet.
main(d86740e) still pins"@faker-js/faker": "~10.2.0"atapps/api/package.json:27.Merging #1660 will not close this issue. Its body says
Closes #1624, #1626, #1618, #1620, ..., but GitHub needs the keyword in front of each number, so #1624 is the only issue linked to the PR. Rewrite that line asCloses #1624,Closes #1626and so on, or close this issue and the other 12 by hand after the merge.The fix in #1660
It moves to
^10.6.0, which is still the latest release on npm. It seedssex: faker.helpers.arrayElement($Sex.options)and drops thetoUpperCaseimport, which nothing else uses. Use that rather than the literal['MALE', 'FEMALE'] as constfrom the issue: the values come from$Sex, so the seeder can't drift from the schema. This is the onlysexType()call in the repo.The new unit test pins the seeded sexes to
$Sex.options. It also passes on the current code, becausesexType()without options never returns'generic'. What actually catches this break istsc.Seeded data
No test asserts on specific seeded values.
demo.service.test.tschecks that the id is the hash of the seeded fields (:145-150), the custom-id numbering (:152-165) and the rating ranges (:186-200). It never checks a name, a date or a sex. The e2e specs create their own subjects through the start-session form, for exampletesting/src/specs/datahub.spec.ts:66.The change needs no new e2e spec. The global setup (
testing/src/global/setup.spec.ts:15-22) seeds 10 subjects with 10 records each throughDemoService.init(apps/api/src/setup/setup.service.ts:100-104), and both thechromiumandfirefoxprojects depend on it (testing/playwright.config.ts:26,:33).Landing
#1660 conflicts with
main. If it stalls, c0d58b9 cherry-picks ontomainby itself without conflicts,pnpm-lock.yamlincluded. I checked this with a three-way merge of each file it touches. Runpnpm installafterwards to confirm the lockfile.The Dependabot PRs #1631 (
~10.5.0) and #1579 (^10.5.0) also move faker past 10.3 without touchingdemo.service.ts. Merging either one would bring back the two TS2345 errors, so neither faker bump should land ahead of this fix.The
Good First Issuelabel can come off, since the fix already exists.Triage note written with Claude Code. Code references point at
main@d86740e.build(api): upgrade faker to 10.6