pierrejeambrun commented on code in PR #43102:
URL: https://github.com/apache/airflow/pull/43102#discussion_r1828138447
##########
airflow/api_fastapi/core_api/serializers/connections.py:
##########
@@ -34,8 +36,23 @@ class ConnectionResponse(BaseModel):
login: str | None
schema_: str | None = Field(alias="schema")
port: int | None
+ password: str | None
extra: str | None
+ @field_validator("password", mode="after")
+ @classmethod
+ def redact_password(cls, v: str | None, field_info: ValidationInfo) -> str
| None:
+ if v is None:
+ return None
+ try:
+ redacted_dict = json.loads(
+ json.dumps(redact(value={field_info.field_name: v},
name=field_info.field_name))
+ )
+ redacted_password = redacted_dict.get(field_info.field_name, "***")
+ return redacted_password
+ except (json.JSONDecodeError, ValueError) as ex:
+ raise ex
Review Comment:
I think all of that was necessary because the `val` of a Variable is a
dictionary with some key / values to redact.
In this case we just need to redact the value, why can't we just `redact(v,
"password")` ?
--
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]