Skip to content

missing-error-response

Id
@azure-tools/typespec-azure-resource-manager/missing-error-response

ARM operations must include a generic @error response for otherwise undeclared failure status codes.

ARM operations must define a response marked with @error and no explicit status code. This generic error response covers failure status codes that are not explicitly declared. The requirement applies to every HTTP method, including HEAD, and to custom and resource operations.

Add CommonTypes.ErrorResponse as a response to the operation. The standard ARM operation templates include this generic error response.

  • Area: API design and generated SDKs

A generic error response gives generated clients a consistent contract for unexpected failure status codes.

Assume Widget is an ARM resource. Removing the template’s error response leaves unexpected failure status codes without an error-response contract.

@armResourceOperations
interface Widgets {
read is ArmResourceRead<Widget, Error = never>;
}
@armResourceOperations
interface Widgets {
read is ArmResourceRead<Widget>;
}

Retain an operation without a generic error response only when required to preserve an existing, ARM-reviewed API contract.

This rule implements the shared ARM error-response guideline from MissingDefaultResponse and RequiredDefaultResponse.