{"record":{"id":"dda7765335c5c601","repo":"rolldown/rolldown","slug":"expected-a-number-payload-but-got-other","errorCode":null,"errorMessage":"expected a number payload, but got {other:?}","messagePattern":"expected a number payload, but got (.+?)","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"crates/rolldown_binding/src/options/plugin/types/binding_filter_expression.rs","lineNumber":36,"sourceCode":"impl BindingFilterTokenPayloadInner {\n  pub fn try_into_string(self) -> anyhow::Result<String> {\n    match self {\n      BindingFilterTokenPayloadInner::StringOrRegex(inner) => inner.try_into_string(),\n      other => anyhow::bail!(\"expected a string payload, but got {other:?}\"),\n    }\n  }\n\n  pub fn try_into_string_or_regex(self) -> anyhow::Result<StringOrRegex> {\n    match self {\n      BindingFilterTokenPayloadInner::StringOrRegex(inner) => Ok(inner),\n      other => anyhow::bail!(\"expected a string or regex payload, but got {other:?}\"),\n    }\n  }\n\n  pub fn try_into_number(self) -> anyhow::Result<u32> {\n    match self {\n      BindingFilterTokenPayloadInner::Number(v) => Ok(v),\n      other => anyhow::bail!(\"expected a number payload, but got {other:?}\"),\n    }\n  }\n\n  pub fn try_into_regex(self) -> anyhow::Result<HybridRegex> {\n    match self {\n      BindingFilterTokenPayloadInner::StringOrRegex(inner) => inner.try_into_regex(),\n      other => anyhow::bail!(\"expected a regex payload, but got {other:?}\"),\n    }\n  }\n}\n\n#[derive(Debug, Clone)]\npub struct BindingFilterTokenPayload(BindingFilterTokenPayloadInner);\n\nimpl BindingFilterTokenPayload {\n  pub fn into_inner(self) -> BindingFilterTokenPayloadInner {\n    self.0\n  }","sourceCodeStart":18,"sourceCodeEnd":54,"githubUrl":"https://github.com/rolldown/rolldown/blob/91b44b9d7bcfb5725533478e044e3891a251b2c5/crates/rolldown_binding/src/options/plugin/types/binding_filter_expression.rs#L18-L54","documentation":"Napi-side type guard in BindingFilterTokenPayloadInner::try_into_number: the filter-expression token payload received from JavaScript was expected to hold a number, but the actual payload variant is shown in the message (e.g. StringOrRegex). It fires when a filter expression built on the JS side places a non-number payload where the consuming token requires a number.","triggerScenarios":"Calling `try_into_number()` on a `StringOrRegex` or `Boolean` payload, e.g. a token intended as numeric (like a query value kind) but built with a string payload.","commonSituations":"Building filter expression tokens programmatically where a numeric token receives a stringified number (`'1'` instead of `1`), or token arrays shifted so the payload pairs with the wrong kind.","solutions":["Pass an actual JS number (not a numeric string) for number tokens","Check token array alignment — a missing token shifts payloads against kinds","Coerce numeric strings with `Number(value)` before constructing the token"],"exampleFix":"// before\n{ kind: 'queryKey', payload: '1' }\n// after\n{ kind: 'queryKey', payload: 1 }","handlingStrategy":"type-guard","validationCode":"if (typeof payload !== 'number' || Number.isNaN(payload)) {\n  throw new TypeError('number token payload required');\n}","typeGuard":"function isNumber(v) {\n  return typeof v === 'number' && !Number.isNaN(v);\n}","tryCatchPattern":"try {\n  const n = payload.tryIntoNumber();\n} catch (e) {\n  console.error('Expected numeric token payload:', e.message);\n  throw e;\n}","preventionTips":["Coerce numeric strings with Number() before building number tokens","Keep token kind and payload types paired in one construction helper","Avoid hand-assembling token arrays"],"tags":["filter-expression","plugin","type-mismatch","rust"],"backgroundTag":"type-mismatch","analyzedSha":"91b44b9d7bcfb5725533478e044e3891a251b2c5","analyzedAt":"2026-09-07T16:04:13.504Z","contentChangedAt":"2026-09-07T16:04:13.504Z","schemaVersion":2},"datasetVersion":"2026-09-17T15:17:12.973Z"}