Repository navigation
fix(logs,metrics,client): make incomplete or failed results visible to scripts; fewer flags - #123
Merged
Merged
Conversation
…o scripts From a failure-mode review of Nubi's workspace path: scripts often drop stderr, so warnings there were easy to lose and a cut-off, partial or failed result could read as the whole answer. - logs query --envelope (-o json): always an object with logs, series and completeness keys (truncated, total, total_relation, partial, series_note, suggestion); the series object carries the same keys. The bare array stays the default for scripts that parse it. - logs query selects partial and warns on stderr when it is set - metrics query exits non-zero when a query in the result failed, after printing its output, so a failure is not read as "no data" - 401: show the server's message when it says why (e.g. an expired workspace token) instead of advice to create an API token; keep that advice for a bare "Unauthorized" or a one-word code (not_authenticated) Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
There was a problem hiding this comment.
Code Review
This pull request introduces several enhancements to the CLI, including a new --envelope flag for logs queries to output completeness metadata (such as truncation and partial results) in JSON format, and updates metrics queries to exit with a non-zero status upon failure. Additionally, the HTTP client now extracts and displays detailed server-side error messages for 401 Unauthorized responses. Feedback suggests using strings.Fields in isBareUnauthorized to more robustly check if an error message consists of a single word.
Review feedback: handles every whitespace character, not just space and tab. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…e and --query-type
Fewer options for people and for Nubi to choose between:
- logs query -o json is always {logs, series, truncated, partial, total,
total_relation, series_note, suggestion} (keys the api-server did not
send are left out); --envelope is gone. Breaking for scripts that parsed
the bare array; no release has shipped it since v0.0.3.
- --query-type is gone from logs query and metrics query; the workspace
proxy defaults Elasticsearch to dsl, and the rare KQL/PPL case is
--param query_type=kql|ppl
- help, README and tests updated
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…in the cut-off warning Limits live in the caller: with no limit (or 0) the api-server falls back to each provider's own default (10 to 5,000 lines) and a cut-off result could not be told from a complete one. --limit now defaults to 1000 to match llm-server's logs default, values below 1 are rejected, and the warning reads 'Returned N lines = --limit N; results may be cut off'. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…alid flags - --query-type still works for logs query and metrics query, as a deprecated alias for --param query_type=<value>: hidden from --help, with a stderr note. About 1 in 12 nbctl calls Nubi made on dev used it; removing it outright would have turned each into a failed call. - An unknown or bad flag now names the command's own flags, e.g. "unknown flag: --metric\nflags for nbctl metrics list-label-values: --account-id, --label (see ... --help)". Set once on the root, so every command, current and future, gets it. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
RamanKharchee
approved these changes
Oct 21, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Follow-up to #122 from a failure-mode review of Nubi's workspace path (nudgebee/nudgebee-enterprise#40463). Scripts often drop stderr, so a cut-off, partial or failed result could read as the whole answer.
Changes
logs query -o jsonhas one shape: always{logs, series, truncated, partial, total, total_relation, series_note, suggestion}. Keys the api-server didn't send are left out. A script that drops stderr still sees whether the result is complete. Breaking for scripts that parsed the bare log array; no release has shipped that array since v0.0.3.--query-typeleaves--helpforlogs queryandmetrics query; use--param query_type=kql|ppl|dsl. It still works as a deprecated alias (stderr note), because about 1 in 12nbctlcalls Nubi made on dev used it. The workspace proxy already defaults Elasticsearch to DSL.unknown flag: --metric/flags for nbctl metrics list-label-values: --account-id, --label). Set once on the root, so every command gets it; Nubi guessed--metricthere 4 times on dev.--limit: defaults to 1000 (llm-server's logs default) and must be at least 1. With no limit, or 0, the api-server would fall back to each provider's default (10 to 5,000 lines), and a cut-off result couldn't be detected. The warning now names the limit:Returned N lines = --limit N; results may be cut off.partial:logs querynow selects it and warns on stderr when the provider didn't finish.metrics query: exits non-zero when a query in the result failed, after printing its output (text or JSON). A failure no longer looks like "no data".Unauthorized, a one-word code such as the app gateway'snot_authenticated, or an empty body.Not changed
A DSL
"size"can return more lines than--limit. That's Elasticsearch's own knob and stays as it is.Testing
make buildpasses (lint,go test -race ./..., build).-o jsonobject, and--query-typehidden from--helpbut still working as a deprecated alias;partialwarning;truncated: true, total: 10000 gte, partial: false; counts give 116 series with an exact total;--param query_type=kqlworks for logs, andquery_type=dslfor metrics;🤖 Generated with Claude Code