{"record":{"id":"d4d3d06d16ae67c9","repo":"pydantic/monty","slug":"unknown-typecheckformat-format-expected-one-of-object-keys","errorCode":null,"errorMessage":"unknown typeCheckFormat '${format}', expected one of: ${Object.keys(TYPE_CHECK_FORMATS).join(', ')}","messagePattern":"unknown typeCheckFormat '(.+?)', expected one of: (.+?)","errorType":"validation","errorClass":"RangeError","httpStatus":null,"severity":"error","filePath":"crates/monty-js/ts/options.ts","lineNumber":46,"sourceCode":"  json: 4,\n  jsonlines: 5,\n  rdjson: 6,\n  pylint: 7,\n  gitlab: 8,\n  github: 9,\n}\n\n/**\n * Encodes a {@link TypeCheckFormat} to its wire number, throwing on an unknown name.\n *\n * The own-property check matters: JavaScript callers are not bound by the\n * type, and a plain lookup would find inherited names like `'toString'` and\n * hand a `Function` to the wire encoder instead of rejecting it here.\n */\nexport function encodeTypeCheckFormat(format: TypeCheckFormat): number {\n  const encoded = Object.hasOwn(TYPE_CHECK_FORMATS, format) ? TYPE_CHECK_FORMATS[format] : undefined\n  if (encoded === undefined) {\n    throw new RangeError(\n      `unknown typeCheckFormat '${format}', expected one of: ${Object.keys(TYPE_CHECK_FORMATS).join(', ')}`,\n    )\n  }\n  return encoded\n}\n\n/**\n * The `assertMessageAnnotations` checkout option: `true`/`false`, or an\n * integer customizing the per-operand repr truncation length (in bytes,\n * default 120) of introspected `assert` failure messages.\n */\nexport type AssertMessageAnnotations = boolean | number\n\n/**\n * Normalizes {@link AssertMessageAnnotations} to the wire encoding of\n * `Configure.assert_message_annotations`: `undefined`/`true` → absent (the\n * child's default, a 120-byte truncation), `false` → `0` (off), an integer →\n * a custom truncation length. Throws `RangeError` for numbers the wire's","sourceCodeStart":28,"sourceCodeEnd":64,"githubUrl":"https://github.com/pydantic/monty/blob/adc986b362e3961f407868cb118a99fe831b9e61/crates/monty-js/ts/options.ts#L28-L64","documentation":"`typeCheckFormat` was given a value that is not one of the recognized format names. The library looks the format up in a `TYPE_CHECK_FORMATS` lookup table using `Object.hasOwn` (so inherited names like `'toString'` are rejected, not passed to the wire encoder) and throws `RangeError` listing the valid keys when the value is absent.","triggerScenarios":"Passing `typeCheckFormat: 'text'`, a misspelled name like `'tyepcheck'`, or a non-string value (e.g. `true`) in `CheckoutOptions` during `pool.checkout(...)`.","commonSituations":"Copying option names from the Python binding or another library, typo after renaming a constant, hand-editing config where the format is stored as a string.","solutions":["Use one of the exact names listed in the error message (the current keys of TYPE_CHECK_FORMATS)","If the value comes from user config, validate/normalize it against the allowed keys before calling checkout","Omit the option entirely to use the library default"],"exampleFix":"// before\nconst session = await pool.checkout({ typeCheck: true, typeCheckFormat: 'text' })\n// after\nconst session = await pool.checkout({ typeCheck: true, typeCheckFormat: 'pyright' })","handlingStrategy":"validation","validationCode":"const VALID = ['pyright', 'off'] // see error message for current keys\nif (!VALID.includes(options.typeCheckFormat)) throw new Error(`bad typeCheckFormat: ${options.typeCheckFormat}`)","typeGuard":"function isTypeCheckFormat(v: unknown): v is TypeCheckFormat {\n  return typeof v === 'string' && Object.hasOwn(TYPE_CHECK_FORMATS, v)\n}","tryCatchPattern":"try {\n  session = await pool.checkout(opts)\n} catch (e) {\n  if (e instanceof RangeError && e.message.startsWith(\"unknown typeCheckFormat\")) {\n    opts.typeCheckFormat = undefined // fall back to default\n    session = await pool.checkout(opts)\n  } else throw e\n}","preventionTips":["Copy option values from the package's TypeScript types, not hand-typed strings","Derive the value from the union type: let the compiler check literal assignment","Validate user-supplied config against the allowed keys before checkout"],"tags":["typescript","options-validation","type-checking"],"backgroundTag":"invalid-enum-value","analyzedSha":"adc986b362e3961f407868cb118a99fe831b9e61","analyzedAt":"2026-09-13T19:19:18.698Z","contentChangedAt":"2026-09-13T19:19:18.698Z","schemaVersion":2},"datasetVersion":"2026-09-14T11:17:12.474Z"}