-
Notifications
You must be signed in to change notification settings - Fork 1.2k
fix(wrangler): vectorize list and list-metadata-index should output valid json #12807
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. Weβll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,5 @@ | ||
| --- | ||
| "wrangler": patch | ||
| --- | ||
|
|
||
| fix: `wrangler vectorize list --json` and `wrangler vectorize list-metadata-index --json` now output valid json without extra log lines |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -26,7 +26,9 @@ export const vectorizeListMetadataIndexCommand = createCommand({ | |
| }, | ||
| positionalArgs: ["name"], | ||
| async handler(args, { config }) { | ||
| logger.log(`π Fetching metadata indexes...`); | ||
| if (!args.json) { | ||
| logger.log(`π Fetching metadata indexes...`); | ||
| } | ||
| const res = await listMetadataIndex(config, args.name); | ||
|
|
||
| if (res.metadataIndexes.length === 0) { | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. π΄ Empty metadata index list with When (Refers to lines 34-42) Was this helpful? React with π or π to provide feedback. |
||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
π΄ Empty index list with
--jsonflag outputs no JSON instead of[]When
wrangler vectorize list --jsonis called and there are no indexes, the empty-check atpackages/wrangler/src/vectorize/list.ts:33runs before the JSON output at line 43. This causes the handler to log a warning vialogger.warn()and return early without ever outputting JSON. A caller expecting valid JSON on stdout will get an empty string, which is not valid JSON. The fix should move theargs.jsoncheck before the empty-length check, or output[]for the empty case when--jsonis set.(Refers to lines 33-41)
Was this helpful? React with π or π to provide feedback.