Skip to content

fix: handle null parent nodes in apply_templated_fields#214

Merged
b-per merged 1 commit into
mainfrom
fix/templated-fields-null-parent
Jun 24, 2026
Merged

fix: handle null parent nodes in apply_templated_fields#214
b-per merged 1 commit into
mainfrom
fix/templated-fields-null-parent

Conversation

@b-per

@b-per b-per commented Jun 24, 2026

Copy link
Copy Markdown
Collaborator

Summary

  • apply_templated_fields crashed with TypeError: argument of type 'NoneType' is not iterable when a job had job_completion_trigger_condition: null and --templated-fields included a dotted path into that field (e.g. job_completion_trigger_condition.condition.project_id)
  • Fixed by treating a null parent node the same as a missing key — replacing it with an empty dict before navigating further
  • Added a regression test covering this case

Context

Triggered when users template nested fields in the job completion trigger condition across multi-environment migrations, where some jobs have job_completion_trigger_condition: null and others do not.

Test plan

  • uv run pytest tests/exporter/test_export.py — all 10 tests pass
  • Run import-jobs --templated-fields with a template that includes job_completion_trigger_condition.condition.project_id against an account that has a mix of jobs with and without a job completion trigger condition

When a job has job_completion_trigger_condition set to null and
--templated-fields includes a dotted path into that field (e.g.
job_completion_trigger_condition.condition.project_id), set_nested_value
would crash with TypeError because it tried to check membership in None.
Treat null parent nodes the same as missing keys by replacing them with
an empty dict before navigating further.
@github-actions

Copy link
Copy Markdown
Contributor

Coverage

Coverage Report
FileStmtsMissCoverMissing
src/dbt_jobs_as_code
   main.py3189470%131–134, 140, 180–181, 214–217, 223, 269, 292–295, 300–303, 314–322, 329–337, 341, 344–346, 419–424, 438–439, 457–458, 462–464, 502, 505, 513–526, 529–532, 573–579, 582, 586, 603, 605, 607, 609, 612–623, 627–628, 668–672, 686, 690, 692, 697–710, 717–718, 722
src/dbt_jobs_as_code/client
   __init__.py2074678%17, 56–57, 65, 126–127, 150–151, 174–175, 190–191, 208–209, 225–226, 245, 255, 335–350, 373, 389–390, 400–412, 415–426, 431–440
src/dbt_jobs_as_code/cloud_yaml_mapping
   change_set.py2353087%27–29, 59, 65–66, 155, 212, 224, 248, 252–253, 259–261, 276–279, 336–350, 403–425, 461–475
src/dbt_jobs_as_code/importer
   __init__.py27774%14–15, 22–27
src/dbt_jobs_as_code/schemas
   __init__.py23291%68, 78
   common_types.py60395%67–68, 91
   config.py14193%18
   job.py141795%252, 257, 273–283
TOTAL122819085% 

Tests Skipped Failures Errors Time
212 0 💤 0 ❌ 0 🔥 15.743s ⏱️

@b-per b-per merged commit 54cf0e3 into main Jun 24, 2026
6 checks passed
@b-per b-per deleted the fix/templated-fields-null-parent branch June 24, 2026 09:06
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant