Repository navigation
fix(jobs): keep omitted settings unchanged on jobs/update - #69
Merged
Merged
Conversation
update_job merged a full dump of new_settings, which carries model defaults for fields the caller never sent, so a tags-only update reset the job name to "Untitled". Merge only the top-level fields present in the request. Nested defaults such as a task's run_if are kept, so updated jobs are stored in the same shape as created ones. Closes dmux#52
Owner
|
Hey @avison9, nice catch on this one! 🙌 It conflicts with Also, a quick test with an extra field (like Thanks! |
Resolve the conflict with 1921949, which made update_job validate a copy of the settings before saving: the sent-fields-only merge now applies to that copy (new_settings), so a rejected update still leaves the job untouched. Add a test with a setting the model doesn't declare (email_notifications): kept when an update omits it, replaced when one sends it.
Contributor
Author
|
Thanks @dmux. Updated:
I merged rather than rebased to avoid force-pushing over the branch; happy to squash on merge if you prefer a single commit. Full suite in Docker ( |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Closes #52
Summary
A partial
jobs/updatethat omitsnamerenamed the job toUntitled.update_jobmerged a fulldump of
new_settingsinto the stored settings, and that dump carries model defaults for fields thecaller never sent. Any SDK or Terraform workflow that edits only tags, timeouts or other settings
silently lost the job's name.
Before / after
Root cause
JobSettings.namedefaults to"Untitled", andupdate_jobusednew_settings.model_dump(exclude_none=True), which includes defaults for omitted fields, so thedefault overwrote the stored name on every update that did not send one.
What changed
update_jobnow merges only the top-level fields the request actually sent(
model_dump(exclude_none=True, include=new_settings.model_fields_set)).model_fields_setalsocovers the
extra="allow"fields, so settings such asemail_notificationsstill merge.The issue suggests
exclude_unset=True. That was considered and not used: it also strips nesteddefaults, so a task sent through update would lose the
run_if: ALL_SUCCESSthatcreate_jobstores, and updated jobs would be stored in a different shape from created ones. Filtering only the
top level keeps the stored shape identical.
reset_jobis unchanged, since a reset replaces thewhole settings object by design.
Testing
Full suite via
docker-compose.test.yml, image rebuilt:pre-commit run --all-filescleanNew tests in
tests/test_jobs.py, using the real databricks-sdk:test_job_partial_update_keeps_omitted_fields[tags-only|timeout-only|empty]: the three caseslisted in the issue. Each asserts the name and tasks survive and the sent field is applied.
test_job_update_with_name_renames: a name that is sent still replaces the stored one, so the fixdoes not turn update into a no-op for
name.Risk
Low. Only
jobs/updateis affected, and only fields the caller did not send behave differently:they are now left alone instead of being reset to model defaults. Fields that are sent merge exactly
as before.