pierrejeambrun commented on code in PR #54034:
URL: https://github.com/apache/airflow/pull/54034#discussion_r2251830613
##########
airflow-core/src/airflow/api_fastapi/core_api/datamodels/connections.py:
##########
@@ -136,3 +136,25 @@ class ConnectionBody(StrictBaseModel):
port: int | None = Field(default=None)
password: str | None = Field(default=None)
extra: str | None = Field(default=None)
+
+ @field_validator("extra")
+ @classmethod
+ def validate_extra(cls, v: str | None) -> str | None:
+ """
+ Validate that `extra` is a JSON-encoded Python dict.
+
+ If `extra` is not a valid JSON, it will be returned as is.
+ """
+ if v is None:
+ return v
+ try:
+ extra_dict = json.loads(v)
+ if not isinstance(extra_dict, dict):
+ raise ValueError("Extra must be a valid JSON object (e.g.,
{'key': 'value'})")
+ except json.JSONDecodeError:
+ # If it's not a valid JSON, we can't redact it, so return as is
Review Comment:
Comment is not related to 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: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]