`dbt_utils.get_url_parameter` will incorrectly match fields if they end with url_parameter
Nobody has claimed this yet.
- Dominant language
- Makefile
- Stars
- 1.8k
- Forks
- 632
- PR merge metrics
- No merged PRs in 30d
Description
Describe the bug
Steps to reproduce
When using dbt_utils.get_url_parameter it will incorrectly match on short
For example when doing the following and the url field values is http://www.test.com?msg=myvalue it will incorrectly return "myvalue".
dbt_utils.get_url_parameter(field='url', url_parameter='g')
Expected results
In the above scenario, it should only exact match the URL parameter and return null
Actual results
It matches and returns "myvalue"
System information
The contents of your packages.yml file:
packages:
- package: dbt-labs/codegen
version: 0.12.1
- package: calogica/dbt_expectations
version: [">=0.9.0", "<0.10.0"]
Which database are you using dbt with?
- postgres
- redshift
- bigquery
- snowflake
- other (specify: ____________)
The output of dbt --version:
1.8.2
Additional context
I believe it's this implementation here https://github.com/dbt-labs/dbt-utils/blob/main/macros/web/get_url_parameter.sql#L5
Are you interested in contributing the fix?
I've switched to using the following but not sure this solution is entirely correct either
nullif(regexp_substr({{ field }}, '[?&]{{ url_parameter }}=([^&]+)', 1, 1, 'e'), '')
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start with macros/web/get_url_parameter.sql at the linked implementation and reproduce the reported call using the URL value and parameter g. Confirm that matching requires the complete parameter name, so a field ending in url_parameter is not treated as an exact match; done means the example returns null while valid exact parameters still return their value.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- sql
- Domain
- databases
- Issue type
- Bug
- Difficulty
- 2/5
- Estimated time
- 1-3 hours
- Activity status
- Stale
- Clarity
- Clearly specified
- Newbie friendliness
- 68/100