Repository navigation
fix: accept cat column lists - #842
margaretjgu wants to merge 1 commit into
Conversation
|
👋 This PR can use the first-failure repair loop on GitHub Actions and Buildkite. Labels
Comments
|
✅MegaLinter analysis: Success
Notices📣 MegaLinter 9.5.0 is out! Discover the new features and security recommendations in the release announcement. (Skip this info by defining See detailed reports in MegaLinter artifacts MegaLinter is graciously provided by OX Security |
Startup perf: PR vs merge-base ✅
|
| // Cat `h` and `s` are a comma-separated list, and the published enum drops | ||
| // the spec aliases (`s`, `dpr`, `mb`). Keep the string and check that it is | ||
| // a string or a list of strings. | ||
| const columnLists = schemaArgs.filter((a) => a.description.startsWith('Comma-separated list of column names')) |
There was a problem hiding this comment.
Another one where the root cause is upstream schema data, not the CLI. A lot of this probably needs to be applied in @elastic/schemas, either via the ES spec or the code generator.
We'd need to ask others on the team if it makes sense to change CatBase.ts in the ES spec to make some of these column types | string unions and add the missing aliases. _cat APIs are kinda weird and special because the intended audience is... CLI users who want ASCII tables. 😆
Or if this has to land as a stopgap, update the PR description to explain why an upstream fix is not possible or that we're blocked on a decision there,
| // Cat `h` and `s` are a comma-separated list, and the published enum drops | ||
| // the spec aliases (`s`, `dpr`, `mb`). Keep the string and check that it is | ||
| // a string or a list of strings. | ||
| const columnLists = schemaArgs.filter((a) => a.description.startsWith('Comma-separated list of column names')) |
There was a problem hiding this comment.
Also: selecting fields by description prefix is fragile. Upstream wording isn't stable, and if it changes upstream, this silently stops matching and #839 comes back. Or if an unrelated field ever starts with this text, it loses validation without anyone noticing.
If a CLI-side exception is the only way, maybe key it on schema structure, or as a hard-coded list of APIs or namespaces.
| for (const f of columnLists) { | ||
| if (f.schemaKey in props) { | ||
| props[f.schemaKey] = { | ||
| anyOf: [{ type: 'string' }, { type: 'array', items: { type: 'string' } }], | ||
| } | ||
| } | ||
| } |
There was a problem hiding this comment.
This drops all column validation for the matched flags. Replacing the schema with string | string[] means typos like --h idd or --s nmae now pass --dry-run for ml-jobs, ml-datafeeds, ml-data-frame-analytics, etc. Those mistakes only show up as a server error at runtime.
If a stopgap is kept, consider splitting on , and checking items against the enum plus the known aliases, or getting the upstream types fixed so anyOf handles it.
Accept a comma separated cat column list, including aliases the published enum dropped. Relates to #839.