Repository navigation
fix(laya-ts): match min_confidence bucket-key error text to Python and Java (#1100) - #1106
Conversation
|
Short answer: the wording change is exactly what #1100 asked for and I'd merge it as-is. One character of the rendered key still differs from Python and Java, and the new regex cannot see it because it stops at I filed #1100, so I checked your build rather than re-deriving it. node --input-type=module -e "import { checkMinConfidenceMap } from '/abs/path/to/common1106.ts'; try { checkMinConfidenceMap({'choice:2-5': 0.5}) } catch (e) { console.log(JSON.stringify(e.message)) }"(the import path has to be absolute — a relative one resolves against the What that printed, with your line applied to
So the divergence left is the quoting of the offending key, and for this message the offending value is always a string, so it appears on every throw. Your anchored regex Either way: this is the fix #1100 describes. Flagging the quoting so whoever closes the issue decides deliberately whether it closes on this PR. |
|
Short answer: this is exactly the wording half of #1100 and it is correct — I ran your head against the suite and against two mutants, and What I measured on your head
The overstatement: "character-for-character parity on this line" holds for the prefix, but not for the whole line. Your So Python and Java agree on the quoting and TypeScript is the odd one out — that is #1100's second half, which you correctly scoped out (it is a Witness that this is live rather than theoretical: I replaced No action needed on the wording half either way — it is done and it is good. Also FYI: your head has 0 check runs attached ( |
|
Thanks @aashish254, that's a really thorough check, and the mutation runs are a nice touch. You're right that "character-for-character parity" overstates it. The prefix through I'll leave the |
|
Merged in 0.4.3, and closing #1100 with it. Two lines, and the reason they matter is in the error's job: it is what a caller reads when they have got the bucket key wrong, and it listed one legal shape while omitting the one that decides whether unnamed buckets get gated at all. A caller told that keys must look like Anchoring the test regex to the full prefix rather than matching a fragment is the part that makes this stick, and it brings TypeScript in line with how Verified on the merged tree: |
What
Aligns the laya-ts bucket-key error text in checkMinConfidenceMap with the reference text in Python (laya/confidence.py) and Java (ConfidenceGate.java):
The test regex in laya-ts/tests/confidence-gating.test.ts is updated and anchored to the full prefix, so the wording is now pinned on the TypeScript side too, the way ConfidenceGateBucketKeyTest.java already pins it for Java.
Why
As described in #1100, the TypeScript message never mentions
default, even though the validator accepts it and it decides whether unnamed buckets get gated at all. A caller who hits this error should learn thatdefaultis a legal key. This also brings the message prefix (everything up to, got) to character-for-character parity with Python and Java. The quoted key after it still differs: TypeScript rendersgot "choice:3_5"where Python and Java rendergot 'choice:3_5', becausepyRepr's string branch usesJSON.stringify.This PR covers only the wording half of #1100. The pyRepr quote-style question (single vs. double quotes across the 10 repr-bearing messages in
common.ts) is a separate decision and is deliberately left alone here.How it was verified
cd laya-ts
npm ci
npx vitest run tests/confidence-gating.test.ts
Test Files 1 passed (1) | Tests 22 passed (22)
Checklist
Fixes #1100