A university NOC built a Flask endpoint that receives Catalyst Center outbound webhooks and routes each event by severity, sending critical events to a shared chat channel and the rest to a log. The reply must return within one second because routing can take six, malformed bodies must be answered with 400, and only valid events may enter the routing queue. Which request-handling sequence satisfies the timing, validation, and severity-routing requirements?
Select an answer to reveal the explanation.
Short Explanation
You parse the body first and return 400 for malformed JSON; for a valid event, you queue it and return 200 without waiting for routing. That keeps your reply non-blocking while a worker sends critical events to chat and the rest to the log.
Full Explanation
The sequence that parses the body, returns 400 for bad JSON, queues valid events, and then returns 200 meets all three requirements. Acknowledging the request after enqueueing keeps the reply within one second even when routing takes six seconds; a worker can then send critical events to the shared chat channel and all other valid events to the log. Handling each request synchronously, routing by severity, and replying only after routing preserves the destinations and validation, but can exceed the one-second limit. Queuing valid events and having a worker send every one to chat provides a prompt reply, but ignores the required distinction between critical and noncritical events. Returning 400 for malformed JSON but queuing every syntactically valid body before a worker checks its fields also allows invalid events into the queue, contrary to the requirement that only valid events be queued. Exam caveat: syntactically valid JSON is not necessarily a valid event; it may lack required fields or contain invalid values. Practical check: test malformed JSON, schema-invalid JSON, and valid critical and noncritical events separately. Confirm that only valid events are queued, the response arrives within one second, and each valid event reaches its severity-based destination.