taylorterwin opened a new issue, #34676:
URL: https://github.com/apache/airflow/issues/34676
### Apache Airflow version
2.7.1
### What happened
In the dbt Airflow provider code (referenced below), a field called
trigger_reason is mapped to the JSON cause key:value pair, that you would
directly set in Postman.
When trigger_reason is not set in Airflow (None) it defaults to creating a
calculated string:
```
```
if self.trigger_reason is None:
self.trigger_reason = (
f"Triggered via Apache Airflow by task {self.task_id!r} in
the {self.dag.dag_id} DAG."
)
```
I'm going to guess that in this case, the trigger_reason isn't set in the
airflow task, and therefore the task_id and the dag_id are both so long (?)
that they are causing this calculated string to exceed 255 characters.
That being said, we should handle this better and truncate it at 254
regardless.
code is here:
https://airflow.apache.org/docs/apache-airflow-providers-dbt-cloud/3.3.0/_modules/airflow/providers/dbt/cloud/operators/dbt.html
### What you think should happen instead
Basically the summary is that on this line;
https://github.com/apache/airflow/blob/bd512007e531bb58e86f8c1b8f84ac20e8e92d7c/airflow/providers/dbt/cloud/operators/dbt.py#L132
`cause ` needs to be limited to 255 characters
### How to reproduce
the trigger_reason creating a calculate string
def trigger_job_run(
self,
job_id: int,
cause: str,
account_id: Optional[int] = None,
steps_override: Optional[List[str]] = None,
schema_override: Optional[str] = None,
additional_run_config: Optional[Dict[str, Any]] = None,
) -> Response:
"""
Triggers a run of a dbt Cloud job.
:param job_id: The ID of a dbt Cloud job.
:param cause: Description of the reason to trigger the job.
[2023-09-26, 08:47:38 EDT] {{http.py:161}} ERROR - HTTP error: Bad Request
[2023-09-26, 08:47:38 EDT] {{http.py:162}} ERROR -
{"status":{"code":400,"is_success":false,"user_message":"The request was
invalid. Please double check the provided data and try
again.","developer_message":""},"data":{"cause":"must be between 0 and 255
characters"}}
### Operating System
unknown
### Versions of Apache Airflow Providers
_No response_
### Deployment
Official Apache Airflow Helm Chart
### Deployment details
_No response_
### Anything else
_No response_
### Are you willing to submit PR?
- [ ] Yes I am willing to submit a PR!
### Code of Conduct
- [X] I agree to follow this project's [Code of
Conduct](https://github.com/apache/airflow/blob/main/CODE_OF_CONDUCT.md)
--
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]