SnowPro Advanced: Security Engineer Question 410
Single answerUse filtered responses (for example, NULL from TRY_COMPLETE())A security engineering team is building a Snowflake Cortex-powered internal assistant that summarizes support tickets. Some tickets may contain sensitive values such as credentials or regulated identifiers. To reduce the risk of exposing blocked content to downstream applications, the team decides to use filtered model responses and call TRY_COMPLETE() instead of COMPLETE(). The assistant stores the model output in a reporting table and must avoid persisting any generated text when the safety system blocks the response. Which approach best meets this requirement?
- A
Insert the result of TRY_COMPLETE() directly into the reporting table and rely on the function returning NULL when the response is filtered, while treating NULL as a blocked response in downstream SQL logic.
- B
Use COMPLETE() instead of TRY_COMPLETE() because COMPLETE() returns an empty string when content is filtered, which is easier to detect than NULL.
- C
Wrap TRY_COMPLETE() with COALESCE(TRY_COMPLETE(...), 'FILTERED') and store the literal string 'FILTERED' as if it were the model response so analysts can review the generated text later.
- D
Call TRY_COMPLETE() and, if it returns NULL, immediately retry the same prompt with a larger warehouse so the model can produce a non-filtered answer.
Show answer and explanation
Correct answer: A
Explanation
The best answer is to use TRY_COMPLETE() and let NULL represent a filtered or otherwise safely suppressed response, then design downstream SQL and application logic to recognize NULL as a blocked result. This is the practical security pattern because it prevents accidental storage or display of model-generated content when the safety layer filters a response. In Snowflake Cortex usage, TRY_* functions generally provide non-throwing behavior by returning NULL instead of raising an error, which is useful for controlled handling in production pipelines. For Security Engineer scenarios, the key principle is not just making the function call succeed, but ensuring blocked responses do not get persisted or exposed through downstream systems. A recommended implementation is to store the response in a nullable column and optionally maintain a separate status or audit column indicating that the generation was filtered, rather than replacing NULL with a fabricated text value.
- A. Correct.
Correct. TRY_COMPLETE() is intended to provide a safer error-handling pattern by returning NULL rather than raising an error in cases such as filtered responses. In this scenario, inserting only the non-NULL result and treating NULL as a blocked response prevents accidental persistence of model-generated content when Snowflake filters the output. This aligns with the requirement to avoid storing generated text for blocked responses.
- B. Incorrect.
Incorrect. COMPLETE() does not return an empty string for filtered content. A common misconception is that filtered output is represented as blank text, but the relevant safe-handling pattern here is to use TRY_COMPLETE(), which can return NULL for filtered responses. Using COMPLETE() would not satisfy the requirement as cleanly and may require exception handling rather than NULL-based logic.
- C. Incorrect.
Incorrect. Although COALESCE can make downstream processing easier, storing a sentinel string such as 'FILTERED' in the same column as generated content can blur the distinction between actual model output and blocked events. More importantly, the requirement is to avoid persisting generated text when blocked, not to create a pseudo-response value that may later be misinterpreted as model output. A better design is to store NULL for the response and track filtering status separately if needed.
- D. Incorrect.
Incorrect. Increasing warehouse size does not change whether a response is filtered by safety controls. Filtering is not caused by insufficient compute. Retrying the same sensitive prompt in hopes of bypassing filtering is not an appropriate security practice and does not meet the requirement to safely handle blocked responses.