Cloud concept · Updated

Request Validation - Request validation checks incoming requests against an explicit contract before allowing them to reach application logic or downstream services.

In short

Request validation determines whether incoming data has the required structure, types, values, and application-specific meaning. In cloud systems, it helps reject malformed or unsupported requests early, protect downstream capacity, and give clients predictable feedback without replacing authentication, authorization, or content safety controls.

Cloud Concepts Hub →

6 key aspects of Request Validation

Effective request validation combines explicit contracts, layered checks, consistent processing rules, and safe failure handling across every entry point.

01
Explicit request contracts

Define required fields, types, allowed values, content types, and size limits for each operation. Keep the contract versioned and test it against both accepted and rejected examples.

02
Structural and semantic checks

Validate payload shape first, then apply rules that depend on meaning or context. A token limit can be a valid integer yet still exceed the selected model's supported limit.

03
Layered server-side enforcement

Use gateway validation for supported basic checks and application code for deeper rules. Treat client-side validation as a usability feature, not proof that incoming requests are trustworthy.

04
Consistent synchronous and asynchronous handling

Apply the same logical contract to direct API calls and queued work. Validate before enqueueing, and check message validity and schema compatibility again at the consumer boundary.

05
Clear failure classification

Distinguish invalid requests from throttling and transient infrastructure failures. Return actionable client errors for synchronous calls and prevent permanently invalid queued messages from consuming repeated processing attempts.

06
Compatibility and observability

Coordinate schema changes across clients, gateways, and workers to avoid inconsistent acceptance rules. Track failures by field or error category while redacting prompts, credentials, and other sensitive data.

Cloud services for Request Validation

Amazon API Gateway REST APIs can reject basic contract violations before forwarding requests to AWS Lambda or another backend. The backend performs semantic and model-specific checks, then uses a language-specific AWS SDK to invoke Amazon Bedrock synchronously or submits validated work to Amazon SQS for asynchronous processing. An SQS consumer checks the message contract and schema version before calling Bedrock. Shared validation rules keep these paths consistent, while separate handling for invalid input and transient failures prevents wasted inference calls and unnecessary retries.

Amazon API GatewayAmazon API Gateway

REST APIs support request validators for required request parameters and request-body models, allowing invalid requests to be rejected before backend integration. Required-parameter validation checks presence and nonblank values, not types or formats; HTTP APIs do not offer the same built-in request-validation feature.

AWS LambdaAWS Lambda

Function code can enforce semantic rules, model-specific constraints, and schema-version compatibility before invoking downstream services. The same validation library can support API handlers and SQS consumers, although deploying a function alone does not enable application-schema validation.

Amazon Bedrock

Bedrock inference APIs enforce their own API and model constraints, but an integrating application must still validate its public request contract. Adapters can translate validated application requests into Converse requests for supported models or model-specific InvokeModel payloads.

Request Validation exam questions

Real practice exam questions on Request Validation, with the correct answer and its explanation. Answer them with every option in the exam simulator.

AIP-C01

A company exposes a text-generation endpoint through an Amazon API Gateway REST API with a Lambda proxy integration. Clients provide an outputTokens query-string parameter. The public contract requires a decimal integer from 1 through 2048; invalid values must receive HTTP 400 without invoking a foundation model.

The API's OpenAPI definition marks outputTokens as required and declares an integer schema with minimum 1 and maximum 2048. A method request validator validates request parameters. However, tests using outputTokens=0, outputTokens=4096, and outputTokens=abc all reach the Lambda function. The function currently forwards the value to Amazon Bedrock. The selected model supports output-token limits greater than 2048.

The company must enforce the contract without changing how clients submit requests or adding another compute component. Which change meets these requirements?

Show answerCORRECT ANSWER

Validate outputTokens in the Lambda handler before constructing the Bedrock request. Reject values that are not decimal integers from 1 through 2048 by returning an HTTP 400 proxy response.

API Gateway REST API request-parameter validation checks required parameters for presence and nonblank values; it does not enforce their declared types or numeric ranges. Explicit validation in the existing Lambda handler preserves the public contract and rejects invalid input before any model invocation.

Practice Request Validation in a full exam

Questions on Request Validation in each practice exam, with every answer option and an explanation for each:

Start a free practice exam

What is Request Validation

3 min read

Request validation defines what a system is willing to accept at an interface. A request contract can specify required fields, supported content types, data types, permitted values, length limits, and relationships between fields. Structural validation checks whether a request matches that contract; semantic validation checks whether its values make sense for the requested operation. For example, an inference request might require a nonempty messages array, a supported model identifier, and an output-token limit within the selected model's supported range.

Cloud applications commonly validate requests at multiple boundaries. An API gateway can reject basic contract violations before invoking a function or container, while application code enforces rules that require configuration, identity context, or external state. Client-side checks improve usability but are not a trusted security boundary because callers can bypass them. Server-side validation remains necessary for custom clients, internal integrations, and messages received from queues.

For a foundation-model integration, expose a stable application-level request format rather than requiring every client to understand each model provider's payload. The backend validates that format, selects an allowed model, and translates the request into the appropriate inference API call. Amazon Bedrock Converse provides a consistent message-oriented interface for supported models, while InvokeModel uses model-specific request bodies. Neither approach eliminates the need to validate application rules, such as supported model-and-feature combinations or tenant-specific limits. Language-specific AWS SDKs simplify request construction and signing, but their validation behavior varies and does not replace application validation.

Amazon API Gateway REST APIs illustrate gateway-level validation. A configured request validator can check required URI, query-string, and header parameters for presence and nonblank values, and validate a request body against an associated model. Parameter checks do not validate parameter types or formats. Body validation depends on the configured model and content-type matching; configure supported content types deliberately and consider a default model where appropriate so an unmatched content type does not bypass the intended checks. Do not assume API Gateway HTTP APIs provide the same built-in request-validation capability as REST APIs. Keep complex cross-field and business-rule validation in application code.

The same contract should apply whether inference runs synchronously or asynchronously. A synchronous handler running in a function, container, or virtual machine can validate input and then call the model through an AWS SDK. For asynchronous processing, validate before placing work on Amazon SQS, and have consumers validate the message envelope and supported schema version before inference. SQS does not validate message bodies against an application schema. Permanently invalid messages should be quarantined or routed through a controlled failure path rather than retried indefinitely; transient downstream failures require a different retry policy.

Validation introduces trade-offs. Strict contracts catch mistakes early but can break older clients when schemas evolve, while overly permissive contracts allow ambiguous inputs to propagate. Version contracts intentionally, test valid and invalid cases, and return useful client-error responses without exposing sensitive payloads. Gateway rejection can save backend execution and model-inference cost, although gateway processing still incurs its own cost. Finally, a structurally valid request can still be unauthorized, malicious, or unsafe: validation is not authentication, authorization, rate limiting, prompt-injection defense, or output validation. Use those controls alongside it, and record validation failures with safe error codes and correlation identifiers rather than routinely logging complete prompts.

Learn Request Validation in lessons

1 short lesson on Request Validation in 1 certification course.

Open the lessons