You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@airflow.apache.org by "Sagargupta16 (via GitHub)" <gi...@apache.org> on 2026/03/04 02:26:54 UTC
[PR] Add template_fields support to SalesforceBulkOperator [airflow]
Sagargupta16 opened a new pull request, #62840:
URL: https://github.com/apache/airflow/pull/62840
## Summary
- Add `template_fields` to `SalesforceBulkOperator` enabling Jinja templating for `operation`, `object_name`, `payload`, and `external_id_field` parameters
- Move input validation from `__init__` to `execute()` so validation runs after template rendering
- Add `test_template_fields` test and update existing validation tests
## Motivation
Closes #62375
Without `template_fields`, parameters like `payload` receive literal template strings (e.g., `{{ ti.xcom_pull(task_ids='upstream_task') }}`) instead of actual XCom values. This change enables dynamic parameterization of the Salesforce Bulk API operator, consistent with how other Airflow operators work.
## Changes
- `providers/salesforce/src/airflow/providers/salesforce/operators/bulk.py`: Added `template_fields` tuple, moved `_validate_inputs()` from `__init__` to `execute()`
- `providers/salesforce/tests/unit/salesforce/operators/test_bulk.py`: Added template_fields test, updated validation tests
## Test plan
- [x] Added `test_template_fields` to verify the tuple is correctly defined
- [x] Updated `test_execute_missing_operation` to verify validation during `execute()`
- [x] Updated `test_execute_missing_object_name` to verify validation during `execute()`
--
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] Add template_fields support to SalesforceBulkOperator [airflow]
Posted by "Sagargupta16 (via GitHub)" <gi...@apache.org>.
Sagargupta16 closed pull request #62840: Add template_fields support to SalesforceBulkOperator
URL: https://github.com/apache/airflow/pull/62840
--
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] Add template_fields support to SalesforceBulkOperator [airflow]
Posted by "boring-cyborg[bot] (via GitHub)" <gi...@apache.org>.
boring-cyborg[bot] commented on PR #62840:
URL: https://github.com/apache/airflow/pull/62840#issuecomment-3994835083
Congratulations on your first Pull Request and welcome to the Apache Airflow community! If you have any issues or are unsure about any anything please check our Contributors' Guide (https://github.com/apache/airflow/blob/main/contributing-docs/README.rst)
Here are some useful points:
- Pay attention to the quality of your code (ruff, mypy and type annotations). Our [prek-hooks]( https://github.com/apache/airflow/blob/main/contributing-docs/08_static_code_checks.rst#prerequisites-for-prek-hooks) will help you with that.
- In case of a new feature add useful documentation (in docstrings or in `docs/` directory). Adding a new operator? Check this short [guide](https://github.com/apache/airflow/blob/main/airflow-core/docs/howto/custom-operator.rst) Consider adding an example DAG that shows how users should use it.
- Consider using [Breeze environment](https://github.com/apache/airflow/blob/main/dev/breeze/doc/README.rst) for testing locally, it's a heavy docker but it ships with a working Airflow and a lot of integrations.
- Be patient and persistent. It might take some time to get a review or get the final approval from Committers.
- Please follow [ASF Code of Conduct](https://www.apache.org/foundation/policies/conduct) for all communication including (but not limited to) comments on Pull Requests, Mailing list and Slack.
- Be sure to read the [Airflow Coding style]( https://github.com/apache/airflow/blob/main/contributing-docs/05_pull_requests.rst#coding-style-and-best-practices).
- Always keep your Pull Requests rebased, otherwise your build might fail due to changes not related to your commits.
Apache Airflow is a community-driven project and together we are making it better 🚀.
In case of doubts contact the developers at:
Mailing List: dev@airflow.apache.org
Slack: https://s.apache.org/airflow-slack
--
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] Add template_fields support to SalesforceBulkOperator [airflow]
Posted by "Copilot (via GitHub)" <gi...@apache.org>.
Copilot commented on code in PR #62840:
URL: https://github.com/apache/airflow/pull/62840#discussion_r2881472832
##########
providers/salesforce/tests/unit/salesforce/operators/test_bulk.py:
##########
@@ -29,6 +29,18 @@ class TestSalesforceBulkOperator:
Test class for SalesforceBulkOperator
"""
+ def test_template_fields(self):
+ """
+ Test that template_fields are correctly defined.
+ """
+ operator = SalesforceBulkOperator(
+ task_id="test_template_fields",
+ operation="insert",
+ object_name="Account",
+ payload=[],
+ )
+ assert operator.template_fields == ("operation", "object_name", "payload", "external_id_field")
+
Review Comment:
`test_template_fields` only asserts the tuple value, but doesn't verify that templating actually works (e.g., that `operation`, `object_name`, and nested values inside `payload` get rendered) nor that validation happens after rendering. Consider rendering the operator with `render_template_fields(...)` (or `operator.render_template_fields(...)`) using a simple Jinja expression and asserting the rendered attributes / that `execute()` succeeds with mocked Salesforce connection.
```suggestion
Test that template_fields are correctly defined and rendered.
"""
operator = SalesforceBulkOperator(
task_id="test_template_fields",
operation="{{ op }}",
object_name="{{ obj }}",
payload=[{"Name": "{{ name }}"}],
)
assert operator.template_fields == ("operation", "object_name", "payload", "external_id_field")
# Verify that templating is applied to all template fields, including nested payload values.
context = {"op": "insert", "obj": "Account", "name": "account1"}
operator.render_template_fields(context=context)
assert operator.operation == "insert"
assert operator.object_name == "Account"
assert operator.payload == [{"Name": "account1"}]
```
--
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