amoghrajesh commented on code in PR #73030:
URL: https://github.com/apache/airflow/pull/73030#discussion_r4102503632


##########
airflow-core/src/airflow/api_fastapi/core_api/datamodels/task_instances.py:
##########
@@ -89,6 +90,17 @@ class TaskInstanceResponse(BaseModel):
     queued_by_job: JobResponse | None = Field(alias="triggerer_job")
     dag_version: DagVersionResponse | None
     team_name: str | None = None
+    state_reason: str | None = Field(default=None, 
validation_alias="retry_reason")
+
+    @field_validator("state_reason", mode="after")
+    @classmethod
+    def redact_state_reason(cls, v: str | None) -> str | None:
+        # A retry policy composes this from the exception text, and a policy 
may opt out of the
+        # worker-side redaction, so the same string that would be masked in a 
task log can reach
+        # here unmasked.
+        if v is None:
+            return None
+        return str(redact(v))

Review Comment:
   Moved the redaction into `_evaluate_retry_policy`, next to where the reason 
is composed, following the RTIF way in the same file. `RetryDecision` is frozen 
so it's rebuilt with `replace()`. One site covers all four consumers and the 
log line.
   
   Kept the validators as defence in depth, with the `cast("str", ...)` fix.
   
   New worker test asserts the exact masked string rather than just absence. 
Ran again to be sure
   
   <img width="2479" height="1185" alt="image" 
src="https://github.com/user-attachments/assets/4c59f889-1fc8-4121-ab73-b1acfc60cdb1";
 />
   
   <img width="2479" height="1185" alt="image" 
src="https://github.com/user-attachments/assets/35f94304-3314-4dc6-86f5-87f37cd4275a";
 />
   



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to