Repository navigation
Add Goa-backed query-svc commands - #23
Conversation
Add `lfx query-svc` with commands for each query service endpoint, built on lfx-v2-query-service's generated Go module. Each command maps urfave flags onto the generated Build<Method>Payload function, so Goa's validation runs before the request, and prints the raw JSON response, with the same --query/-q gjson filter as `lfx api`. Each endpoint is an ordered table of builder parameters. TestGoaBuilderSignatures parses the generated source and checks the tables in order, because a reordering of same-typed string parameters would still compile. It also keeps service flags off names reserved for output flags; suggest-orgs' search text is --search for this reason. Also add an upgrade-maintenance skill for reconciling these tables when service modules change, help examples for common queries, and share the no-redirect HTTP client with `lfx api`. Resolves: #21 Assisted-by: github-copilot:claude-opus-5.5 Signed-off-by: Eric Searcy <eric@linuxfoundation.org>
Assisted-by: github-copilot:claude-opus-5.5 Signed-off-by: Eric Searcy <eric@linuxfoundation.org>
There was a problem hiding this comment.
🟡 Changes recommended
Flag-to-payload conversion lacks parser-based test coverage, and the domain flag help advertises URLs that validation rejects.
2 open issues
What changed in this PR
Adds lfx query-svc as the first Goa-backed service command group, establishing a reusable integration pattern while retaining urfave/cli and existing authentication.
Changes:
- Exposes five read-only query endpoints with validated flags, raw JSON output, and
--queryfiltering. - Adds shared Goa plumbing and tests that check builder parameter order and flag collisions.
- Documents usage and dependency-maintenance procedures; write commands remain deferred to #22.
| File | Description |
|---|---|
README.md |
Documents service commands with query examples. |
internal/commands/query.go |
Defines five query-service endpoints and their flags. |
internal/commands/goa.go |
Adds shared command construction, payload conversion, and response handling. |
internal/commands/goa_test.go |
Checks builder signatures and reserved flag names. |
internal/commands/api.go |
Extracts shared HTTP-client and output-filter helpers. |
go.sum |
Records checksums for new dependencies. |
go.mod |
Adds query-service, Goa, and supporting dependencies. |
cmd/lfx/main.go |
Registers the query-service command group. |
AGENTS.md |
Documents the Goa integration and maintenance pattern. |
.agents/skills/upgrade-maintenance/SKILL.md |
Defines dependency-upgrade and argument-table reconciliation procedures. |
Review effort: Balanced
Assisted-by: github-copilot:claude-opus-5.5 Signed-off-by: Eric Searcy <eric@linuxfoundation.org>
Address review comments from copilot-pull-request-reviewer on PR #23: - internal/commands/query.go: describe --domain as a bare domain name, matching the builder's domain-only validation. - internal/commands/goa_payload_test.go: add one table-driven test of the shared flag-to-builder conversion, using a stand-in builder with one argument per kind: defaults, omitted lists, repeated comma-containing list values, bearer-token insertion and builder error passthrough. - AGENTS.md: note that this test covers argument kinds, not services, so new services and endpoints do not need their own payload tests. Resolves 2 review threads. Assisted-by: github-copilot:claude-opus-5.5 Signed-off-by: Eric Searcy <eric@linuxfoundation.org>
Assisted-by: github-copilot:claude-opus-5.5 Signed-off-by: Eric Searcy <eric@linuxfoundation.org>
Assisted-by: github-copilot:claude-opus-5.5 Signed-off-by: Eric Searcy <eric@linuxfoundation.org>
Assisted-by: github-copilot:claude-opus-5.5 Signed-off-by: Eric Searcy <eric@linuxfoundation.org>
Bump goa.design/goa/v3 to v3.34.0 (newest release compatible with the go1.26 toolchain policy target) and go-chi/chi/v5 to v5.5.0. Also bump go.mod's go directive to the latest 1.26 patch, 1.26.10. Assisted-by: github-copilot:claude-sonnet-5 Signed-off-by: Eric Searcy <eric@linuxfoundation.org>
andrest50
left a comment
There was a problem hiding this comment.
This PR adds lfx query-svc, the first Goa-backed command group. Each endpoint is a table of builder parameters mapped to flags, and the command calls the generated Build<Method>Payload through reflection so Goa's validation applies. It prints the service's raw JSON and keeps lfx api's --query behavior. It does what the description says, and the shared plumbing is small and easy to extend.
What's done well
TestGoaBuilderSignaturesparses the generated source to catch reordered same-typed string parameters, which compile but silently misroute flags.DisableSliceFlagSeparatoris set on the endpoint command. I checked urfave/cli v3.14.0: it is applied per command to that command's own flags (command.go:573), so it still works when nested underlfx.- The no-redirect HTTP client is now shared with
lfx api, so the bearer token can't leak across a downgrade redirect. - The next-page token is in the response body at v0.4.33 (
page_tokenintypes.go), so printing only the body doesn't hide pagination.
Outside the diff
- README lost security-relevant notes. The restructure deleted two passages and didn't re-add them: "Automatic browser opening accepts only absolute HTTPS URLs… control characters in login instructions are escaped", and "the base URL is not configurable per call". The second is only partly covered by the new "Later commands send requests to the API for the environment you logged in to". Please restore both under "Authentication" and "Raw API calls". (Minor)
godirective bump, 1.26.9 to 1.26.10. AGENTS.md saysgo get -uupgrades modules only, not the toolchain. Was the bump forced by a new dependency, or did it come fromgo get -u? If it's forced, a line in the description would help. (Question)
Reconciliation with existing reviews
- ✅ Copilot: parser-based tests for flag-to-payload conversion. Resolved by
TestGoaFlagsToBuilderArgs(332c5f2). - ✅ Copilot:
--domainhelp advertised URLs. Resolved; the help now says "no scheme or path". ⚠️ github-license-complianceongo.mod(BSD-3-Clause AND the Go patent grant) is still open. This is the usual license of Go'sx/modules, so it's probably a false positive. It needs a policy allow-list entry or a maintainer sign-off, or the check may block merge.
Issue count
- 🔴 Blocking: 0
- 🟡 Major: 0
- 🔵 Minor: 3 (the dead
Pathfield, untestedformatGoaError/rawBodyDoer, and the README gap above) - ⚪ Nit: 2
- ❔ Question: 1
Decision
Approving: there are no blocking or major findings. I'd like the Path and README items addressed before merge, and the license check resolved.
Address review comments from the reviewers on PR #23: - internal/commands/goa.go, internal/commands/query.go: removed the unused goaService.Path field; its serviceURL was built but only Scheme/Host reached NewClient, since the generated client already emits each endpoint's full path. run() now validates baseURL directly. - internal/commands/goa.go: added a default case to endpointCommand's flag-building switch that panics on an unsupported goaArgKind, matching goaBuilderValues's existing error for the same case. - internal/commands/goa.go: capped rawBodyDoer's response body read with io.LimitReader (maxGoaResponseBodyBytes, 64 MiB) instead of an unbounded io.ReadAll. - internal/commands/goa_response_test.go: added TestFormatGoaError (named error with/without Message, plus an ordinary error) and TestRawBodyDoer (keeps a readable copy of the body while leaving resp.Body readable). Resolves 4 review threads. Assisted-by: github-copilot:claude-sonnet-5 Signed-off-by: Eric Searcy <eric@linuxfoundation.org>
Address additional review feedback on PR #23: - internal/commands/api.go, internal/commands/goa.go: extracted resolveAuthenticatedBaseURL, shared by `lfx api` and every Goa-backed command, to fix a jscpd duplicate-code finding introduced by the earlier Path-field removal (both had resolved the access token, environment, and base URL with the same sequence). - .agents/skills/upgrade-maintenance/SKILL.md: reformatted both reference tables with markdown-table-formatter and shortened one cell over MD013's line-length limit, clearing markdownlint findings. Assisted-by: github-copilot:claude-sonnet-5 Signed-off-by: Eric Searcy <eric@linuxfoundation.org>
|
@andrest50 replying to your review (#23 (review)):
README lost security-relevant notes. After discussion, I'm not restoring either passage, for different reasons for each:
Thanks for the thorough review — addressed the |
Review Feedback AddressedChanges Made
Questions Answered
No Change Needed
Feedback Items Addressed6 of 7 actionable feedback items addressed in this iteration (4 code-change threads, 1 question, 1 no-change-needed explanation). Threads Resolved4 of 5 initially unresolved threads resolved in this iteration. Still Open
|
internal/commands/api.go, internal/commands/goa.go: extracted a shared readLimitedBody helper that reads one byte past the limit and returns a distinct error when a body is larger than that, instead of silently truncating it. io.LimitReader alone returns a clean EOF at the limit, so an oversized-but-otherwise-valid response could reach the Goa decoder as truncated JSON and fail with a misleading "unexpected EOF" rather than identifying the client-side size limit as the cause. `lfx api`'s --query branch now also enforces a 64 MiB cap via the same helper, closing a gap where it had no response-size limit at all. Assisted-by: github-copilot:claude-sonnet-5 Signed-off-by: Eric Searcy <eric@linuxfoundation.org>
internal/commands/api.go: revive flags a parameter named max as a redefinition of Go's built-in max function; renamed to limit. Assisted-by: github-copilot:claude-sonnet-5 Signed-off-by: Eric Searcy <eric@linuxfoundation.org>


Summary
Adds
lfx query-svc, the first set of commands generated from an LFX v2 service's Goa module, and settles the approach investigated in #21.Findings from #21
gen/http/cli/...) can't be wrapped. ItsParseEndpointreads the globalos.Args, exits the process on a bad flag, and writes usage straight to stderr.Build<Method>Payloadfunctions. These take one string per parameter and apply Goa's validation and type parsing. lfx calls them directly from urfave flags.lfx auth: the stored token, and the environment's API base URL plus the service path.Changes
internal/commands/goa.go: shared plumbing for Goa-backed commands. Each endpoint is an ordered table of builder parameters, each mapped to a flag. The command calls the builder, prints the service's raw JSON, supports--query/-qlikelfx api, and gives readable messages for Goa's typed errors.internal/commands/api.go,internal/commands/goa.go: shareresolveAuthenticatedBaseURL(access token, environment, and base URL resolution) betweenlfx apiand Goa-backed commands, and the no-redirect HTTP client and--queryoutput helper.internal/commands/query.go: query-svc tables (query-resources,query-resources-count,query-membership-summary,query-orgs,suggest-orgs) and help examples.internal/commands/goa_test.go:TestGoaBuilderSignaturesreads the generated source and checks each table against the builder's parameter names in order. Reordered same-type string parameters would still compile, so this catches that and fails on added, removed or renamed parameters. It also rejects service flags that collide with reserved output flags;suggest-orgsuses--searchbecause--queryis reserved.internal/commands/goa_payload_test.go:TestGoaFlagsToBuilderArgschecks the shared flag-to-builder conversion once per argument kind with a stand-in builder; new services do not need their own payload tests..agents/skills/upgrade-maintenance/SKILL.md: new skill for reconciling these tables when service modules change, adapted from lfx-mcp's.AGENTS.md,README.md: document the pattern and the new commands.go.mod/go.sum: routinego get -u ./... && go mod tidydependency refresh (goa.design/goa/v3tov3.34.0, the newest release compatible with the repo's go1.26 toolchain policy target;go-chi/chi/v5tov5.5.0;go.mod'sgodirective to the latest 1.26 patch,1.26.10). Nolfx-v2-*service module changed, so no Goa-backed command reconciliation was needed.Testing
make checkandmake testpass, includingTestGoaFlagsToBuilderArgs(defaults, omitted and repeated comma-containing lists, token insertion, builder errors).TestGoaBuilderSignaturesfailed as intended.-q, and committee search by parent and name.goaService.Pathfield, added adefaultcase for an unsupportedgoaArgKind, cappedrawBodyDoer's response read, addedTestFormatGoaError/TestRawBodyDoer, extractedresolveAuthenticatedBaseURLto fix a jscpd duplicate-code finding, reformattedSKILL.md's tables to clear markdownlint findings, and extracted a sharedreadLimitedBodyhelper so an oversized response body is rejected with a clear error instead of silently truncated, applying the same 64 MiB cap tolfx api's--querybranch for consistency.Follow-up
Write commands (fetch, merge, then PUT with
If-Matchand strict decoding, as in linuxfoundation/lfx-mcp#196) are tracked in #22. Query service is read-only and doesn't need them.Resolves: #21
🤖 Generated with GitHub Copilot (via OpenCode)