Skip to content

Allow expected HTTP status codes #151

Description

@jongio

Problem

Automation often needs to treat 404, 409, or 202 as valid. Today azd rest has generic exit codes documented in web/src/pages/reference.astro. Scripts have to parse output or relax error handling when an Azure API returns an expected status outside 2xx.

Proposed solution

Add a persistent --allow-status flag in cli/src/internal/cmd/root.go and config.Config. Accept comma-separated exact codes and ranges like 200-204,404. In the client response handling, return success when the response status matches while still printing the response body. Keep current behavior when the flag is omitted, and document the flag on the reference page.

User impact

People writing provisioning and cleanup scripts can handle idempotent cases without brittle shell workarounds. This is most useful for existence checks, create-if-missing flows, and cleanup commands.

Acceptance criteria

  • --allow-status 404 exits 0 for a 404 response and still writes the response body using the selected format.
  • Ranges like 200-204,409 are accepted, and invalid specs return exit code 2 with a clear error.
  • Tests cover allowed status, disallowed status, invalid flag input, and default behavior.

Notes

Complexity: S • Priority: 5

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    dx-ideaFeature idea generated by idea-generatorenhancementNew feature or requestideaFeature idea from the idea pipeline

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions