feat: store [[identifier]] in job description with --use-desc-for-id#208
Conversation
When use_desc_for_id=True, embed [[identifier]] at the end of the job description instead of the job name, keeping the name clean in the UI.
…data Adds use_desc_for_id: bool = False parameter to DBTCloud.__init__ (stored as _use_desc_for_id) and implements _pre_process_job_data which moves [[identifier]] tags from job description back to job name for internal processing.
…od, immutability test)
…c_for_id Wire _pre_process_job_data into get_job and get_jobs so that when use_desc_for_id=True, [[identifier]] tags are moved from description back to name before constructing JobDefinition objects.
When use_desc_for_id=True on the DBTCloud client, update_job and create_job now embed [[identifier]] in the job description instead of the name when calling to_payload().
Add use_desc_for_id: bool = False parameter to build_change_set() and forward it to the DBTCloud constructor call inside the function.
…t_jobs, link, unlink Exposes the use_desc_for_id flag as a reusable click option with envvar DBT_JOBS_AS_CODE_USE_DESC_FOR_ID and wires it through to build_change_set() (sync, plan) and DBTCloud() (validate, import_jobs, link, unlink).
… commands Add the missing @option_use_desc_for_id decorator and use_desc_for_id kwarg to DBTCloud() in deactivate_jobs, matching the pattern used by all other commands. Add five new tests (validate, import_jobs, link, unlink, deactivate_jobs) that verify DBTCloud is constructed with use_desc_for_id=True when the flag is passed.
…hen use_desc_for_id When use_desc_for_id=True, the API response has [[id]] in description. Now update_job and create_job call _pre_process_job_data on the response before building the returned JobDefinition, matching get_job's existing behavior.
Coverage Report
|
|||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Hi, @b-per , Thank you for the changes! I tested them and they do work, but not exactly as I initially expected. I’ll outline my testing steps below and would really appreciate your support in reviewing them: Current situation: step 0. set
|
|
Hi @savagegipsy, thanks for the detailed report! The workflow you described at the end is actually the correct one — you just skipped the export DBT_JOBS_AS_CODE_USE_DESC_FOR_ID=True
# Step 1 — generate the YAML
dbt-jobs-as-code import-jobs --account-id xxx -j 1051254 --include-linked-id > jobs/test_job.yml
# Step 2 — link (this is the step that was missing)
dbt-jobs-as-code link jobs/test_job.yml
# Step 3 — plan now shows 0 changes
dbt-jobs-as-code plan jobs/test_job.yml
# Step 4 — sync makes no changes
dbt-jobs-as-code sync jobs/test_job.yml
Running |
@b-per Thanks a lot for the clear explanation and the quick help! Just wanted to check if there’s any estimated timeline for when this feature might be merged? |
|
CI passed |
|
@savagegipsy this has been added to 1.18.0 |

Summary
--use-desc-for-idflag (env var:DBT_JOBS_AS_CODE_USE_DESC_FOR_ID) that moves the[[identifier]]tag from the job name to the job description, keeping job names clean in the dbt Cloud UIsync,plan,validate,import_jobs,link,unlink,deactivate_jobsHow it works
--use-desc-for-idmodename"Daily job [[daily_job]]""Daily job"description"Runs nightly""Runs nightly [[daily_job]]"When reading back from the API, the identifier is extracted from whichever field carries it and stripped, so
JobDefinition.nameand.descriptionare always clean internally.Migration
To migrate existing jobs from name-mode to desc-mode: run
unlink, thenlink --use-desc-for-id.Test Plan
uv run pytest tests/)TestIdentifierExtraction(desc methods),TestToPayloadDescMode,TestPreProcessJobData,TestGetJobsDescMode,TestUpdateCreateDescModeDBTCloud/build_change_setCloses #174