Skip to content

fix: show an empty GET response as no resource found (EMSR-2795) - #1036

Merged
katc1004 merged 2 commits into
mainfrom
kchern/EMSR-2795/empty-get-response
Nov 17, 2026
Merged

katc1004 merged 2 commits into
mainfrom
kchern/EMSR-2795/empty-get-response

Conversation

@katc1004

@katc1004 katc1004 commented Nov 16, 2026 •

Copy link
Copy Markdown
Contributor

Summary

When a response has no body, the generated command handler prints {"key": "<last path parameter>"}. The comment on that code says it assumes a delete or a replace, where the key is the resource the user acted on. The production spec now has a GET that returns 204 with no body: GET .../environments/{environmentKey}/default-release-plan when the environment has no default release plan. With that spec (#1031), ldcli environment-release-plans-beta get-default prints {"key": "approvals"} for an environment with no default, which looks like a plan named after the environment. Bugbot and @joannerd flagged it on #1031.

Changes

  • makeRequest keeps the {"key": ...} fallback for every method except GET. A GET with no body now prints {} in JSON output and No <resource> returned in plaintext and markdown output, and exits 0, because the API reported success with nothing to return.
  • The fallback stays for PUT and POST as well as DELETE. 14 PUT and POST operations in the spec return an empty success body, for example code-refs replace-branch and follow-flags replace-flag-follower, and they print the key they acted on today.

No generated file changes. With the spec on main, no GET returns an empty body, so this change is not visible until #1031 merges.

Testing

Automated Tests

cmd/resources/empty_response_test.go runs four generated commands through the real handler with a mock client that returns an empty body: a GET in JSON mode, a GET in plaintext mode, a GET on a beta resource, and a DELETE. Without the fix, the three GET cases fail and the DELETE case passes. go test ./... and golangci-lint run pass.

Manual Tests

With #1031 checked out on top of this change, against catamorphic project kathytest:

$ ldcli environment-release-plans-beta get-default --project kathytest --environment approvals --output json
{}
$ ldcli environment-release-plans-beta get-default --project kathytest --environment approvals --output plaintext
No environment release plans returned
$ ldcli flag-release-plans-beta delete --project kathytest --plan ldcli-smoke-2 --output json
{"key": "ldcli-smoke-2"}

Rollout

This is a change to one hand-written function with no effect on today's commands. It can merge before or after #1031. If it merges after, get-default prints the wrong key until the next release.

No feature flags. To roll back, revert the commit.

🤖 Generated with Claude Code


Note

Overview
Generated resource commands no longer treat an empty GET body as a synthetic {"key": "<last path param>"} object.

GET with a successful empty response now prints {} in JSON mode or No <resource> returned in plaintext (resource name derived from the parent command, with -beta stripped). DELETE and other non-GET methods with empty bodies still echo the last path parameter as {"key": ...}.

Adds empty_response_test.go to lock in JSON/plaintext GET behavior, beta resource naming in the message, and unchanged DELETE output.

Reviewed by Cursor Bugbot for commit a546e8a. Bugbot is set up for automated code reviews on this repo. Configure here.


Related Jira issue: EMSR-2795: Release ldcli version with flag-release-plans-beta commands (generated from openapi)

When a response has no body, the generated command handler prints
the last path parameter as the key. That fits a delete or a replace.
It does not fit a GET that returns 204, such as the default release
plan of an environment that has none, where the output looked like a
plan named after the environment.

A GET with no body now prints {} in JSON output and "No <resource>
found" in plaintext output. Other methods keep the key output.
Ticket: EMSR-2795.

Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
@katc1004
katc1004 marked this pull request as ready for review November 16, 2026 20:33
@katc1004
katc1004 requested a review from a team as a code owner November 16, 2026 20:33
@katc1004
katc1004 requested review from a team and ld-ahartmann and removed request for a team November 16, 2026 20:33
Comment thread cmd/resources/resources.go Resolved
"No <resource> found" is not true for get-default, because the
environment can have release plans and still have no default.
"No <resource> returned" describes every empty GET.

Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
@katc1004
katc1004 merged commit 9b9f5c5 into main Nov 17, 2026
13 checks passed
@katc1004
katc1004 deleted the kchern/EMSR-2795/empty-get-response branch November 17, 2026 21:08
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants