pierrejeambrun commented on code in PR #65452:
URL: https://github.com/apache/airflow/pull/65452#discussion_r3304781827


##########
airflow-core/newsfragments/65452.bugfix.rst:
##########
@@ -0,0 +1 @@
+Return ``"value": null`` (HTTP 200) from ``GET /variables/{key}`` when the 
stored value cannot be decrypted, matching ``GET /variables`` instead of 
failing with HTTP 500.

Review Comment:
   To remove. We do not use newsfragment unless it's 'significant' one.



##########
airflow-core/src/airflow/api_fastapi/core_api/datamodels/variables.py:
##########
@@ -33,13 +33,21 @@ class VariableResponse(BaseModel):
     """Variable serializer for responses."""
 
     key: str
-    val: str = Field(alias="value")
+    # ``val`` is intentionally Optional. ``Variable.get_val`` returns ``None`` 
when
+    # the stored value cannot be decrypted (e.g. after a Fernet key rotation or
+    # misconfiguration). Declaring the field as nullable surfaces that state as
+    # ``"value": null`` in the response instead of raising HTTP 500 due to
+    # response-schema validation. This also matches the behavior of the list
+    # endpoint which has always returned ``null`` in the same scenario.
+    val: str | None = Field(alias="value", default=None)

Review Comment:
   Comment too verbose. I would remove it all together. 



##########
airflow-core/src/airflow/api_fastapi/core_api/datamodels/variables.py:
##########
@@ -33,13 +33,21 @@ class VariableResponse(BaseModel):
     """Variable serializer for responses."""
 
     key: str
-    val: str = Field(alias="value")
+    # ``val`` is intentionally Optional. ``Variable.get_val`` returns ``None`` 
when
+    # the stored value cannot be decrypted (e.g. after a Fernet key rotation or
+    # misconfiguration). Declaring the field as nullable surfaces that state as
+    # ``"value": null`` in the response instead of raising HTTP 500 due to
+    # response-schema validation. This also matches the behavior of the list
+    # endpoint which has always returned ``null`` in the same scenario.
+    val: str | None = Field(alias="value", default=None)
     description: str | None
     is_encrypted: bool
     team_name: str | None
 
     @model_validator(mode="after")
     def redact_val(self) -> Self:
+        # Skip redaction when decryption failed upstream; there is nothing to 
mask
+        # and ``None`` must be preserved so clients can detect the failure.

Review Comment:
   to remove.



-- 
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