fix: reject identifier keys containing special characters#200
Merged
Conversation
The regex used to extract identifiers from dbt Cloud job names only allows [a-zA-Z0-9_-]. Characters like & would silently cause extraction to return None, making every run treat those jobs as new and create duplicates. Add VALID_IDENTIFIER_RE to schemas/job.py as a single source of truth and update _validate_job_identifiers in the loader to enforce it, raising a clear LoadingJobsYAMLError instead of failing silently later. Closes #199
Contributor
Coverage Report
|
|||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
Collaborator
Author
|
CI passed |
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.
Summary
VALID_IDENTIFIER_RE = re.compile(r"^[a-zA-Z0-9_-]+$")toschemas/job.pyas the single source of truth for what characters are valid in a job identifier_validate_job_identifiersin the loader to use it, replacing the spaces-only checkLoadingJobsYAMLErrorat load time instead of silently failing during the dbt Cloud round-tripRoot cause (Closes #199)
Identifiers are embedded in job names as
[[identifier]]and extracted via regex when fetching from dbt Cloud. The extraction regex only allows[a-zA-Z0-9_-]— any other character (e.g.&) causes extraction to returnNone, making the job invisible to the matching logic. On every subsequent run the tool treats the job as new and creates a duplicate.The previous validator only rejected spaces; characters like
&,@,.passed through silently.