mirror of
https://github.com/vercel/workflow.git
synced 2026-09-14 19:59:43 +08:00
Do not depend on an unreleased world export for the flag cap
The --attribute cap was imported from @workflow/world, where the constant is added by a different branch, so on main it resolved to undefined and `values.length > undefined` was always false: the flag accepted any number of pairs and the test for it never threw. Declare the cap in the CLI instead. The World and the backend enforce the same bound independently, and this copy exists only so the error can name the flag the user typed rather than the parameter it becomes. Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
This commit is contained in:
@@ -1,4 +1,13 @@
|
||||
import { ANALYTICS_MAX_ATTRIBUTE_FILTERS } from '@workflow/world';
|
||||
/**
|
||||
* Cap on `--attribute` flags, mirroring the bound the backend applies to an
|
||||
* attribute prefilter.
|
||||
*
|
||||
* Declared here rather than imported so this command does not depend on
|
||||
* `@workflow/world` exporting it. The World and the backend enforce the same
|
||||
* bound independently; this copy exists only so the error can name the flag
|
||||
* the user typed instead of the parameter it becomes.
|
||||
*/
|
||||
const MAX_ATTRIBUTE_FLAGS = 8;
|
||||
|
||||
/**
|
||||
* Parse repeated `--attribute key=value` flags into the filter the analytics
|
||||
@@ -14,9 +23,9 @@ export function parseAttributeFilters(
|
||||
values: string[] | undefined
|
||||
): Record<string, string> | undefined {
|
||||
if (!values?.length) return undefined;
|
||||
if (values.length > ANALYTICS_MAX_ATTRIBUTE_FILTERS) {
|
||||
if (values.length > MAX_ATTRIBUTE_FLAGS) {
|
||||
throw new Error(
|
||||
`--attribute may be given at most ${ANALYTICS_MAX_ATTRIBUTE_FILTERS} times (received ${values.length})`
|
||||
`--attribute may be given at most ${MAX_ATTRIBUTE_FLAGS} times (received ${values.length})`
|
||||
);
|
||||
}
|
||||
const attributes: Record<string, string> = {};
|
||||
|
||||
Reference in New Issue
Block a user