Repository navigation
fix: accept cat column lists #842
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: fix/numeric-union-flags
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 |
|---|---|---|
|
|
@@ -599,14 +599,25 @@ async function validateAgainstSchema ( | |
| merged.sortParsedKeys.has(a.schemaKey) || | ||
| (a.foundIn === 'body' && (a.type === 'object' || a.type === 'array')) | ||
| ) | ||
| if (relaxFields.length > 0 && typeof schema['properties'] === 'object') { | ||
| // 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')) | ||
|
Member
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. 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. |
||
| if ((relaxFields.length > 0 || columnLists.length > 0) && typeof schema['properties'] === 'object') { | ||
| const props = { ...(schema['properties'] as Record<string, unknown>) } | ||
| for (const f of relaxFields) { | ||
| if (f.schemaKey in props) { | ||
| // Accept any value for these relaxed fields | ||
| props[f.schemaKey] = {} | ||
| } | ||
| } | ||
| for (const f of columnLists) { | ||
| if (f.schemaKey in props) { | ||
| props[f.schemaKey] = { | ||
| anyOf: [{ type: 'string' }, { type: 'array', items: { type: 'string' } }], | ||
| } | ||
| } | ||
| } | ||
|
Comment on lines
+614
to
+620
Member
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. This drops all column validation for the matched flags. Replacing the schema with If a stopgap is kept, consider splitting on |
||
| validationSchema = { ...schema, properties: props } | ||
| } | ||
|
|
||
|
|
||
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.
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.tsin the ES spec to make some of these column types| stringunions and add the missing aliases._catAPIs 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,