[p5.js 2.0+ Bug Report]: FES omits parameter position for any parameter after the first
Most appropriate sub-area of p5.js?
- [ ] Accessibility
- [ ] Color
- [ ] Core/Environment/Rendering
- [ ] Data
- [ ] DOM
- [ ] Events
- [ ] Image
- [ ] IO
- [ ] Math
- [ ] Typography
- [ ] Utilities
- [ ] WebGL
- [ ] WebGPU
- [ ] p5.strands
- [ ] Build process
- [ ] Unit testing
- [x] Internationalization
- [x] Friendly errors
- [ ] Other (specify if possible)
p5.js version
current main (2.x dev)
Web browser and version
Chrome for Testing (Chromium, via Vitest browser runner)
Operating system
macOS
Steps to reproduce this
Any function whose parameter validation fails on the second or later parameter produces a message with the position word missing and a doubled space:
Expected string at the parameter in loadModel().
Failures on the first parameter are correct:
Expected Color at the first parameter in background().
Reproduction
npx vitest run test/unit/visual/cases/webgl.js 2>&1 | grep "Expected"
Eight instances from loadModel(), all missing the ordinal, alongside a correct background() message in the same run.
Cause
src/friendly_errors/fes.js:134 holds a single-entry lookup:
ordinals: [TL.tl`first`],
param_validator.js reads it in the invalid_type (line 539) and custom (line 553) branches:
const position = FES.premade.ordinals[currentError.path.join('.')];
Any Zod error path other than [0] returns undefined. Line 542 interpolates it with no guard, so undefined renders as an empty string between two spaces.
Confirmed by adding a temporary log in the invalid_type branch:
PATH: [1] ORDINAL: undefined (loadModel — broken)
PATH: [0] ORDINAL: first (texture — correct)
Origin
Commit f5b75951b ("Work in progress proof of concept FES revamp using new translation utility", Apr 2026) introduced FES.premade.ordinals with the single placeholder entry and pointed these two branches at it.
param_validator.js:107 still holds the complete list — 'first' through 'tenth' — from the earlier implementation, but only buildTypeMismatchMessage uses it. So the file has two ordinal lists and the branches that matter use the incomplete one.
Related prior work: #4626 / PR #4629 added localised ordinals in v1.1.3. The proposal there was "a list of ordinal full forms (first, second, third, ...) for numbers 1 to 10 for all languages in the translation files", which is presumably what FES.premade.ordinals was intended to become.
Scope
Affects every p5 function whose validation fails after the first parameter, not just loadModel.
I'd like to work on this if approved, but since the fix touches translation strings I'd want a steward's view on the right approach first.
Node v22.22.2, Vitest 4.1.10.
Hey @Shruti2110-coder is it open for contribution?
I’m working on this. Once it’s assigned to me, I’ll proceed with it. I’m currently waiting for it to be assigned.
This looks resolved on current main (e1b320b). Running your repro:
npx vitest run test/unit/visual/cases/webgl.js 2>&1 | grep "Expected"
🌸 p5.js says: [webgl.js, line 366] Expected string at the second parameter in loadModel().
… (the same for lines 383, 402, 421, 437, 486, 503, 518)
🌸 p5.js says: [webgl.js, line 2554] Expected Color at the first parameter in background().
All eight loadModel() messages now carry the ordinal, with no doubled space.
The cause was what you identified — FES.premade.ordinals held only the one entry, so any path other than [0] interpolated undefined. It was filled in since: 53ec221 ("Add a few more utility translation strings", 2026-09-26) added second through tenth as TL.tl strings, which is roughly the direction #4629 proposed. param_validator.js:107 still has its own plain-English ordinals array used by buildTypeMismatchMessage, so the two lists you noted are still both there — worth a separate tidy-up issue if anyone wants the duplication gone, but it no longer produces a wrong message.
Flagging it so this can be closed; @yashgoyal0110, that's why it's no longer reproducible.