Lee-W commented on code in PR #54308:
URL: https://github.com/apache/airflow/pull/54308#discussion_r2278415296
##########
airflow-core/src/airflow/api_fastapi/core_api/routes/public/hitl.py:
##########
@@ -119,6 +119,29 @@ def _update_hitl_detail(
"and is not allowed to write again.",
)
+ user_id = user.get_id()
+
+ if hitl_detail_model.respondents:
+ if isinstance(user_id, int):
+ # FabAuthManager (ab_user) store user id as integer, but common
interface is string type
+ user_id = str(user_id)
+ if user_id not in hitl_detail_model.respondents:
+ log.error("User=%s[%s] is not a respondent for the task", user_id,
type(user_id))
Review Comment:
Why do we need `type(user_id)` 🤔
##########
airflow-core/src/airflow/api_fastapi/core_api/routes/public/hitl.py:
##########
@@ -119,6 +119,29 @@ def _update_hitl_detail(
"and is not allowed to write again.",
)
+ user_id = user.get_id()
+
+ if hitl_detail_model.respondents:
+ if isinstance(user_id, int):
+ # FabAuthManager (ab_user) store user id as integer, but common
interface is string type
+ user_id = str(user_id)
+ if user_id not in hitl_detail_model.respondents:
+ log.error("User=%s[%s] is not a respondent for the task", user_id,
type(user_id))
+ raise HTTPException(
+ status.HTTP_403_FORBIDDEN, f"User={user_id} is not a
respondent for the task."
+ )
+ user_id = user.get_id()
+
+ if hitl_detail_model.respondents:
+ if isinstance(user_id, int):
+ # FabAuthManager (ab_user) store user id as integer, but common
interface is string type
+ user_id = str(user_id)
+ if user_id not in hitl_detail_model.respondents:
+ log.error("User=%s[%s] is not a respondent for the task", user_id,
type(user_id))
+ raise HTTPException(
+ status.HTTP_403_FORBIDDEN, f"User={user_id} is not a
respondent for the task."
+ )
Review Comment:
```suggestion
```
looks like redundant code 🤔
##########
airflow-core/src/airflow/api_fastapi/execution_api/routes/hitl.py:
##########
@@ -62,6 +62,7 @@ def upsert_hitl_detail(
"""
ti_id_str = str(task_instance_id)
hitl_detail_model =
session.scalar(select(HITLDetail).where(HITLDetail.ti_id == ti_id_str))
+ # TODO: check the username in the respondents are valid users.
Review Comment:
```suggestion
```
according to your experiment result, I think there's no easy way to achieve
it based on current airflow design. let's remove it
--
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]