You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@airflow.apache.org by "potiuk (via GitHub)" <gi...@apache.org> on 2026/06/01 20:58:44 UTC

[PR] Redact sensitive values in trigger kwargs returned by the REST API [airflow]

potiuk opened a new pull request, #67868:
URL: https://github.com/apache/airflow/pull/67868

   ## Why
   
   `Connection` extras, `Variable` values and rendered task fields are all run
   through Airflow's shared secrets masker before the REST API returns them, so
   sensitive values are shown as `***`. Trigger `kwargs` (`TriggerResponse.kwargs`)
   are the one remaining API response that skips this step and serialises the
   decrypted kwargs verbatim — so a value a deferred operator passes to its
   trigger (an API key, a token, …) is returned as-is. This brings trigger
   kwargs in line with the rest of the API.
   
   ## What
   
   - `TriggerResponse.kwargs` now runs the decrypted kwargs through
     `airflow._shared.secrets_masker.redact()` before serialising — the same
     helper the Connections / Variables / Assets datamodels already use.
     Sensitive keys are replaced with `***`; the triggerer still decrypts and
     uses the real kwargs at runtime, so trigger execution is unaffected.
   - Extended `DEFAULT_SENSITIVE_FIELDS` with credential field names that
     providers use but the set did not cover yet: `app_key`, `certificate_data`,
     `client_key`, `consumer_key`, `credential`, `key_file_dict`, `ssl_key`,
     `yc_sa_key_json`. Matching is substring-based, so e.g. `tls_client_key` and
     `ssl_client_key` are covered by `client_key`.
   
   ## Tests
   
   - New `test_deferred_trigger_kwargs_are_redacted`: a deferred task's trigger
     kwargs are masked in the task-instance response, non-sensitive values pass
     through.
   - Full `shared/secrets_masker` suite passes with the enriched field set.
   
   🤖 Generated with [Claude Code](https://claude.com/claude-code)
   


-- 
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: commits-unsubscribe@airflow.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] Remove trigger kwargs from the REST API response [airflow]

Posted by "ashb (via GitHub)" <gi...@apache.org>.
ashb commented on code in PR #67868:
URL: https://github.com/apache/airflow/pull/67868#discussion_r3395225652


##########
airflow-core/src/airflow/api_fastapi/core_api/datamodels/trigger.py:
##########
@@ -24,14 +24,29 @@
 from airflow.api_fastapi.core_api.base import BaseModel
 
 
+def _redact_kwargs(_: object) -> str:

Review Comment:
   Nit: While this technical is redaction, Can we call this as 
   ```suggestion
   def _remove_kwargs(_: object) -> str:
   ```
   instead? As it doesn't follow ever other use of redaction in Airflow.



##########
airflow-core/src/airflow/api_fastapi/core_api/datamodels/trigger.py:
##########
@@ -24,14 +24,29 @@
 from airflow.api_fastapi.core_api.base import BaseModel
 
 
+def _redact_kwargs(_: object) -> str:
+    """
+    Return empty trigger kwargs for API responses.
+
+    Trigger ``kwargs`` may contain sensitive values (for example credentials a deferred
+    operator hands to its trigger -- an API key, a token), so they are never exposed through
+    the REST API. The field is kept in the response schema for backwards compatibility -- so
+    existing API consumers do not break on a missing property -- but it is always returned
+    empty, as ``"{}"`` (the stringified empty dict, matching the string format the field has
+    always used). The triggerer still decrypts and uses the real kwargs at runtime; only the
+    API representation is emptied.
+    """
+    return "{}"
+
+
 class TriggerResponse(BaseModel):
     """Trigger serializer for responses."""
 
     model_config = ConfigDict(populate_by_name=True)
 
     id: int
     classpath: str
-    kwargs: Annotated[str, BeforeValidator(str)]
+    kwargs: Annotated[str, BeforeValidator(_redact_kwargs)]

Review Comment:
   The other thing we could do is this:
   
   ```suggestion
       kwargs: Annotated[str, BeforeValidator(_redact_kwargs)]
     @computed_field
     @property  
     @deprecated  
     def kwargs(self) -> str:
       # Trigger ``kwargs`` may contain sensitive values (for example credentials a deferred
       # operator hands to its trigger -- an API key, a token), so they are never exposed through
       # the REST API. The field is kept in the response schema for backwards compatibility -- so
       # existing API consumers do not break on a missing property -- but it is always returned
       # empty, as ``"{}"`` (the stringified empty dict, matching the string format the field has
       # always used). The triggerer still decrypts and uses the real kwargs at runtime; only the
       # API representation is emptied.
       return "{}"
   ```
   
   (comment, not doc string, so that string doesn't appear in the API docs. Up to you if you think it's useful to include something/the full thing for API docs.



##########
airflow-core/src/airflow/api_fastapi/core_api/datamodels/trigger.py:
##########
@@ -24,14 +24,29 @@
 from airflow.api_fastapi.core_api.base import BaseModel
 
 
+def _redact_kwargs(_: object) -> str:
+    """
+    Return empty trigger kwargs for API responses.
+
+    Trigger ``kwargs`` may contain sensitive values (for example credentials a deferred
+    operator hands to its trigger -- an API key, a token), so they are never exposed through
+    the REST API. The field is kept in the response schema for backwards compatibility -- so
+    existing API consumers do not break on a missing property -- but it is always returned
+    empty, as ``"{}"`` (the stringified empty dict, matching the string format the field has
+    always used). The triggerer still decrypts and uses the real kwargs at runtime; only the
+    API representation is emptied.
+    """
+    return "{}"
+
+
 class TriggerResponse(BaseModel):
     """Trigger serializer for responses."""
 
     model_config = ConfigDict(populate_by_name=True)
 
     id: int
     classpath: str
-    kwargs: Annotated[str, BeforeValidator(str)]
+    kwargs: Annotated[str, BeforeValidator(_redact_kwargs)]

Review Comment:
   Lets mark this field as deprecated https://pydantic.dev/docs/validation/latest/concepts/fields/#deprecated-fields - and make sure that we don't issue a warning from our own code.



-- 
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: commits-unsubscribe@airflow.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] Redact sensitive values in trigger kwargs returned by the REST API [airflow]

Posted by "ashb (via GitHub)" <gi...@apache.org>.
ashb commented on code in PR #67868:
URL: https://github.com/apache/airflow/pull/67868#discussion_r3339189891


##########
airflow-core/src/airflow/api_fastapi/core_api/datamodels/trigger.py:
##########
@@ -17,21 +17,34 @@
 from __future__ import annotations
 
 from datetime import datetime
-from typing import Annotated
+from typing import Annotated, Any
 
 from pydantic import BeforeValidator, ConfigDict
 
+from airflow._shared.secrets_masker import redact
 from airflow.api_fastapi.core_api.base import BaseModel
 
 
+def redact_kwargs(value: Any) -> str:
+    """
+    Redact sensitive values from trigger kwargs before they are exposed via the API.
+
+    Trigger kwargs may carry credential material (for example an API key handed to a
+    deferred operator). They are encrypted at rest, but this response decrypts them, so
+    sensitive keys are masked here for consistency with how connection extras, variables
+    and rendered fields are already redacted.
+    """
+    return str(redact(value))

Review Comment:
   This will fundamentally break any trigger that gets caught by this. This is not merely display. It is changing the value that the Trigger class sees. 
   
   You say:
   
   > the triggerer still decrypts and
   uses the real kwargs at runtime, so trigger execution is unaffected.
   
   But how/where is that done?



-- 
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: commits-unsubscribe@airflow.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] Remove trigger kwargs from the REST API response [airflow]

Posted by "potiuk (via GitHub)" <gi...@apache.org>.
potiuk merged PR #67868:
URL: https://github.com/apache/airflow/pull/67868


-- 
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: commits-unsubscribe@airflow.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] Redact sensitive values in trigger kwargs returned by the REST API [airflow]

Posted by "potiuk (via GitHub)" <gi...@apache.org>.
potiuk commented on code in PR #67868:
URL: https://github.com/apache/airflow/pull/67868#discussion_r3343251333


##########
airflow-core/src/airflow/api_fastapi/core_api/datamodels/trigger.py:
##########
@@ -17,21 +17,34 @@
 from __future__ import annotations
 
 from datetime import datetime
-from typing import Annotated
+from typing import Annotated, Any
 
 from pydantic import BeforeValidator, ConfigDict
 
+from airflow._shared.secrets_masker import redact
 from airflow.api_fastapi.core_api.base import BaseModel
 
 
+def redact_kwargs(value: Any) -> str:
+    """
+    Redact sensitive values from trigger kwargs before they are exposed via the API.
+
+    Trigger kwargs may carry credential material (for example an API key handed to a
+    deferred operator). They are encrypted at rest, but this response decrypts them, so
+    sensitive keys are masked here for consistency with how connection extras, variables
+    and rendered fields are already redacted.
+    """
+    return str(redact(value))

Review Comment:
   > But how/where is that done?
   
   The `redact_kwargs` is only called explicitly and only in one place - in the "TriggerResponse" that is passed as the regular API response (not TaskSDK). 
   
   We are running it in BeforeValidator, which means that this redaction takes place before the response is prepared to be wired to be sent as response of API call.
   
   https://pydantic.dev/docs/validation/latest/api/pydantic/functional_validators/#pydantic.functional_validators.BeforeValidator
   
   I looked where TriggerResponse - and seems that this class is only used in responses in regular REST API.
   
   or am I wrong @ashb ?
   



-- 
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: commits-unsubscribe@airflow.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] Remove trigger kwargs from the REST API response [airflow]

Posted by "potiuk (via GitHub)" <gi...@apache.org>.
potiuk commented on code in PR #67868:
URL: https://github.com/apache/airflow/pull/67868#discussion_r3408765234


##########
airflow-core/src/airflow/api_fastapi/core_api/openapi/v2-rest-api-generated.yaml:
##########
@@ -16418,7 +16415,6 @@ components:
       required:
       - id
       - classpath
-      - kwargs

Review Comment:
   If we have a clear idea what to do - yes, but I see it more as potential follow up for someone who would like to remove it - I want to keep it minimal to fix the potential issues.



-- 
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: commits-unsubscribe@airflow.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] Remove trigger kwargs from the REST API response [airflow]

Posted by "potiuk (via GitHub)" <gi...@apache.org>.
potiuk commented on PR #67868:
URL: https://github.com/apache/airflow/pull/67868#issuecomment-4627078131

   Thanks @ashb — reworked based on your feedback. Rather than removing the field (which, as you noted, would be a breaking schema change for downstream consumers), `TriggerResponse.kwargs` is now **retained** in the schema but always returned empty as `"{}"`.
   
   Addressing your specific points:
   
   - **Not breaking:** the field stays and keeps its existing `str` type, so the OpenAPI schema is unchanged — no missing-property errors for consumers, and no regenerated spec/UI client.
   - **On the `str()` concern:** I kept it a string deliberately (it has always been one) rather than switching to an object, to avoid a schema type change. Since the value is now a constant `"{}"`, it no longer leaks the real kwargs and no longer depends on stringifying a meaningful dict — `"{}"` is exactly what an empty-kwargs trigger already serialized to under the old `str()` behavior.
   - The triggerer still decrypts and uses the real kwargs at runtime; only the API representation is emptied.
   
   Added a unit test asserting sensitive kwargs are redacted to `"{}"`, and updated the newsfragment. Could you take another look when you get a chance?
   
   ---
   Drafted-by: Claude Code (Opus 4.8); reviewed by @potiuk before posting
   


-- 
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: commits-unsubscribe@airflow.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] Remove trigger kwargs from the REST API response [airflow]

Posted by "potiuk (via GitHub)" <gi...@apache.org>.
potiuk commented on code in PR #67868:
URL: https://github.com/apache/airflow/pull/67868#discussion_r3408767485


##########
airflow-core/src/airflow/api_fastapi/core_api/openapi/v2-rest-api-generated.yaml:
##########
@@ -16418,7 +16415,6 @@ components:
       required:
       - id
       - classpath
-      - kwargs

Review Comment:
   But yeah... Let me see to that - if easy - we can fold it in and it will be even more "explicit" than newsfragments.



-- 
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: commits-unsubscribe@airflow.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] Redact sensitive values in trigger kwargs returned by the REST API [airflow]

Posted by "ashb (via GitHub)" <gi...@apache.org>.
ashb commented on PR #67868:
URL: https://github.com/apache/airflow/pull/67868#issuecomment-4603000017

   Thinking about it, if this is part of the normal public API, not something used by the triggerer directly, perhaps we should just remove the trigger_kwargs from the response entirely?


-- 
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: commits-unsubscribe@airflow.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] Redact sensitive values in trigger kwargs returned by the REST API [airflow]

Posted by "ashb (via GitHub)" <gi...@apache.org>.
ashb commented on code in PR #67868:
URL: https://github.com/apache/airflow/pull/67868#discussion_r3339189891


##########
airflow-core/src/airflow/api_fastapi/core_api/datamodels/trigger.py:
##########
@@ -17,21 +17,34 @@
 from __future__ import annotations
 
 from datetime import datetime
-from typing import Annotated
+from typing import Annotated, Any
 
 from pydantic import BeforeValidator, ConfigDict
 
+from airflow._shared.secrets_masker import redact
 from airflow.api_fastapi.core_api.base import BaseModel
 
 
+def redact_kwargs(value: Any) -> str:
+    """
+    Redact sensitive values from trigger kwargs before they are exposed via the API.
+
+    Trigger kwargs may carry credential material (for example an API key handed to a
+    deferred operator). They are encrypted at rest, but this response decrypts them, so
+    sensitive keys are masked here for consistency with how connection extras, variables
+    and rendered fields are already redacted.
+    """
+    return str(redact(value))

Review Comment:
   This will fundamentally break any trigger that gets caught by this. This is not merely display. It is changing the value that the Trigger class sees. 
   
   You are trusting AI without understanding the problem domain 



-- 
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: commits-unsubscribe@airflow.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] Remove trigger kwargs from the REST API response [airflow]

Posted by "ashb (via GitHub)" <gi...@apache.org>.
ashb commented on code in PR #67868:
URL: https://github.com/apache/airflow/pull/67868#discussion_r3395203676


##########
airflow-core/src/airflow/api_fastapi/core_api/openapi/v2-rest-api-generated.yaml:
##########
@@ -16418,7 +16415,6 @@ components:
       required:
       - id
       - classpath
-      - kwargs

Review Comment:
   I think there's a way of marking a field as deprecated in the OpenAPI schema. That might be apt here.



-- 
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: commits-unsubscribe@airflow.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] Redact sensitive values in trigger kwargs returned by the REST API [airflow]

Posted by "ashb (via GitHub)" <gi...@apache.org>.
ashb commented on code in PR #67868:
URL: https://github.com/apache/airflow/pull/67868#discussion_r3348146588


##########
airflow-core/tests/unit/api_fastapi/core_api/routes/public/test_task_instances.py:
##########
@@ -413,6 +413,32 @@ def test_should_respond_200_with_task_state_in_deferred(self, test_client, sessi
             },
         }
 
+    @pytest.mark.enable_redact
+    def test_deferred_trigger_kwargs_are_redacted(self, test_client, session):
+        """Sensitive values in a deferred task's trigger kwargs must be masked in the API response."""
+        now = pendulum.now("UTC")
+        ti = self.create_task_instances(
+            session, task_instances=[{"state": State.DEFERRED}], update_extras=True
+        )[0]
+        ti.trigger = Trigger(
+            "none",
+            {"gemini_api_key": "super-secret-value-123", "polling_interval": 30},
+        )
+        ti.trigger.created_date = now
+        ti.triggerer_job = Job()
+        TriggererJobRunner(job=ti.triggerer_job)
+        ti.triggerer_job.state = "running"
+        session.commit()
+        response = test_client.get(
+            "/dags/example_python_operator/dagRuns/TEST_DAG_RUN_ID/taskInstances/print_the_context"
+        )
+        assert response.status_code == 200
+        kwargs = response.json()["trigger"]["kwargs"]
+        # The sensitive value is masked; the key name and non-sensitive values are preserved.
+        assert "super-secret-value-123" not in kwargs
+        assert "'gemini_api_key': '***'" in kwargs
+        assert "'polling_interval': 30" in kwargs

Review Comment:
   ```suggestion
           # The sensitive value is masked; the key name and non-sensitive values are preserved.
           assert kwargs == {"gemini_api_key": "***", "polling_interval": 30}
   ```



##########
airflow-core/src/airflow/api_fastapi/core_api/datamodels/trigger.py:
##########
@@ -17,21 +17,34 @@
 from __future__ import annotations
 
 from datetime import datetime
-from typing import Annotated
+from typing import Annotated, Any
 
 from pydantic import BeforeValidator, ConfigDict
 
+from airflow._shared.secrets_masker import redact
 from airflow.api_fastapi.core_api.base import BaseModel
 
 
+def redact_kwargs(value: Any) -> str:
+    """
+    Redact sensitive values from trigger kwargs before they are exposed via the API.
+
+    Trigger kwargs may carry credential material (for example an API key handed to a
+    deferred operator). They are encrypted at rest, but this response decrypts them, so
+    sensitive keys are masked here for consistency with how connection extras, variables
+    and rendered fields are already redacted.
+    """
+    return str(redact(value))

Review Comment:
   Ah no I was wrong.
   
   So my other comment (about is this even worth returning stands) but if it does make sense to keep this:
   
   This shouldn't have `str()` on it -- value is almost certainly a dict, which means this is relying on the stringification of a python dict, rather than keeping it as a json value.



-- 
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: commits-unsubscribe@airflow.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] Remove trigger kwargs from the REST API response [airflow]

Posted by "potiuk (via GitHub)" <gi...@apache.org>.
potiuk commented on PR #67868:
URL: https://github.com/apache/airflow/pull/67868#issuecomment-4700272043

   Pushed an update addressing the remaining review nits, then rebased onto latest `main`.
   
   **Changes since the last review:**
   - Renamed `_redact_kwargs` → `_remove_kwargs` (the value is emptied, not redacted).
   - Marked the `kwargs` field as `deprecated` so the OpenAPI schema now carries `deprecated: true` — this folds in the deprecation we discussed on the spec thread, and it shows up in the generated YAMLs and the UI TypeScript client (`@deprecated` JSDoc).
   - I went with a plain `Field(deprecated=True)` rather than a `@computed_field(deprecated=True)`: the computed-field variant emits a `DeprecationWarning` on every `model_dump()` — i.e. on every deferred-task API response — which is the "don't issue a warning from our own code" case you flagged. A plain deprecated field only warns on direct attribute access, not during serialization, so response rendering stays warning-free. The unit test reads through `model_dump()` accordingly.
   - Regenerated the REST + private-UI OpenAPI specs and the UI client.
   
   Also rebased onto current `main` (the branch was ~50 commits behind), which cleared a stale, unrelated `team`-field deletion the old generated specs had drifted into.
   
   ---
   Drafted-by: Claude Code (Opus 4.8); reviewed by @potiuk before posting


-- 
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: commits-unsubscribe@airflow.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] Remove trigger kwargs from the REST API response [airflow]

Posted by "potiuk (via GitHub)" <gi...@apache.org>.
potiuk commented on code in PR #67868:
URL: https://github.com/apache/airflow/pull/67868#discussion_r3359306048


##########
airflow-core/src/airflow/api_fastapi/core_api/openapi/v2-rest-api-generated.yaml:
##########
@@ -16418,7 +16415,6 @@ components:
       required:
       - id
       - classpath
-      - kwargs

Review Comment:
   Yeah. Thought about it - what we could do instead is to leave it in but make it always empty. That is far less of a breaking change - the schema would remain and we could simply state in a documentation that it is here for historical reasons but kwargs are never populated. 
   
   I think this is. a bit of "Have cake and eat it too".



-- 
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: commits-unsubscribe@airflow.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] Remove trigger kwargs from the REST API response [airflow]

Posted by "potiuk (via GitHub)" <gi...@apache.org>.
potiuk commented on PR #67868:
URL: https://github.com/apache/airflow/pull/67868#issuecomment-4617324703

   Good call — dropped `kwargs` from `TriggerResponse` entirely rather than masking it. It only ever exposed the decrypted trigger kwargs (potential credentials) as a stringified `dict`, and it isn't read by the UI; the triggerer keeps decrypting and using the real kwargs at runtime, so nothing downstream changes. Regenerated the v2 + private-UI OpenAPI specs and the TS client, and updated the task-instance tests. Force-pushed the rewrite.
   
   ---
   Drafted-by: Claude Code (Opus 4.8); reviewed by @potiuk before posting


-- 
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: commits-unsubscribe@airflow.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] Remove trigger kwargs from the REST API response [airflow]

Posted by "ashb (via GitHub)" <gi...@apache.org>.
ashb commented on code in PR #67868:
URL: https://github.com/apache/airflow/pull/67868#discussion_r3353785778


##########
airflow-core/src/airflow/api_fastapi/core_api/openapi/v2-rest-api-generated.yaml:
##########
@@ -16418,7 +16415,6 @@ components:
       required:
       - id
       - classpath
-      - kwargs

Review Comment:
   Hmmmm, though removing this field means it's a breaking change on the API, and could possibly cause down stream consumers to fail with "no such property" type errors



-- 
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: commits-unsubscribe@airflow.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] Remove trigger kwargs from the REST API response [airflow]

Posted by "pierrejeambrun (via GitHub)" <gi...@apache.org>.
pierrejeambrun commented on code in PR #67868:
URL: https://github.com/apache/airflow/pull/67868#discussion_r3414210009


##########
airflow-core/src/airflow/api_fastapi/core_api/datamodels/trigger.py:
##########
@@ -19,19 +19,37 @@
 from datetime import datetime
 from typing import Annotated
 
-from pydantic import BeforeValidator, ConfigDict
+from pydantic import BeforeValidator, ConfigDict, Field
 
 from airflow.api_fastapi.core_api.base import BaseModel
 
 
+def _remove_kwargs(_: object) -> str:
+    """
+    Return empty trigger kwargs for API responses.
+
+    Trigger ``kwargs`` may contain sensitive values (for example credentials a deferred
+    operator hands to its trigger -- an API key, a token), so they are never exposed through
+    the REST API. The field is kept in the response schema for backwards compatibility -- so

Review Comment:
   Making the field always empty is somehow still breaking because people could rely on some fields being there.
   
   Removing it altogether for sake of security was probably also fine at this point.



##########
airflow-core/newsfragments/67868.bugfix.rst:
##########
@@ -0,0 +1 @@
+The ``kwargs`` field of trigger objects returned by the REST API (for example in the ``trigger`` of a task-instance response) no longer exposes the decrypted trigger keyword arguments. Those kwargs can contain credentials a deferred operator hands to its trigger (an API key, a token, …), so the field is now always returned empty, as ``"{}"``. The field is retained in the response schema for backwards compatibility — and is now marked ``deprecated`` there so consumers are nudged off it — and the triggerer still decrypts and uses the real kwargs at runtime; only the API representation is emptied.

Review Comment:
   Not sure why we end up with a `bugfix` newsfragment. 
   
   I thought we were doing significant only. (which could be an option for this change too)



-- 
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: commits-unsubscribe@airflow.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org