{"record":{"id":"22a7518dc3b08eb5","repo":"chroma-core/chroma","slug":"min-requires-at-least-one-rank-expression","errorCode":null,"errorMessage":"Min requires at least one rank expression","messagePattern":"Min requires at least one rank expression","errorType":"exception","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"clients/new-js/packages/chromadb/src/execution/expression/rank.ts","lineNumber":556,"sourceCode":"export const Exp = (input: RankInput): RankExpression =>\n  requireRank(input, \"Exp\").exp();\n\nexport const Log = (input: RankInput): RankExpression =>\n  requireRank(input, \"Log\").log();\n\nexport const Max = (...inputs: RankInput[]): RankExpression => {\n  if (inputs.length === 0) {\n    throw new Error(\"Max requires at least one rank expression\");\n  }\n  const expressions = inputs.map((rank, index) =>\n    requireRank(rank, `Max operand ${index}`),\n  );\n  return MaxRankExpression.create(expressions);\n};\n\nexport const Min = (...inputs: RankInput[]): RankExpression => {\n  if (inputs.length === 0) {\n    throw new Error(\"Min requires at least one rank expression\");\n  }\n  const expressions = inputs.map((rank, index) =>\n    requireRank(rank, `Min operand ${index}`),\n  );\n  return MinRankExpression.create(expressions);\n};\n","sourceCodeStart":538,"sourceCodeEnd":563,"githubUrl":"https://github.com/chroma-core/chroma/blob/aecdd12c8a891610db8653630b066b32ceb678b5/clients/new-js/packages/chromadb/src/execution/expression/rank.ts#L538-L563","documentation":"Thrown by the Min rank factory (rank.ts:556) when called with zero arguments. Min builds {$min: [...]} and requires at least one rank expression. Like Max, expr.min() with no args is a no-op returning expr; the factory Min() with no operands throws.","triggerScenarios":"Calling Min(); spreading a dynamic list Min(...penalties) where penalties is empty — e.g. all penalty components were disabled in configuration.","commonSituations":"Min-over-penalty-components scoring (take the worst penalty); optional-factor pipelines where every factor is behind a flag that is off; empty arrays from upstream data queries.","solutions":["Pass at least one operand: Min(a, b)","Provide a neutral element for the empty case (e.g. a large sentinel or 0 depending on semantics): Min(...(list.length ? list : [0]))","Skip the expression when the list is empty"],"exampleFix":"// before\nconst rank = Min(...penalties); // throws when penalties is []\n\n// after\nconst rank = penalties.length ? Min(...penalties) : Val(0);","handlingStrategy":"validation","validationCode":"const rank = penalties.length\n  ? Min(...penalties)\n  : Val(0);","typeGuard":null,"tryCatchPattern":"try {\n  const rank = Min(...penalties);\n} catch (e) {\n  if (e instanceof Error && e.message.includes('Min requires')) {\n    return Val(0);\n  }\n  throw e;\n}","preventionTips":["Keep a default penalty operand in dynamic pipelines","Gate on penalties.length before spreading"],"tags":["min","rank-expression","empty-arguments","input-validation"],"backgroundTag":"missing-required-argument","analyzedSha":"aecdd12c8a891610db8653630b066b32ceb678b5","analyzedAt":"2026-08-16T21:53:27.228Z","schemaVersion":2},"datasetVersion":"2026-08-16T23:17:17.608Z"}