Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

dbt_utils.get_url_parameter will incorrectly match fields if they end with url_parameter #980

Open
1 of 5 tasks
jasonlanderson opened this issue Jan 11, 2025 · 0 comments
Labels
bug Something isn't working triage

Comments

@jasonlanderson
Copy link

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'), '')

@jasonlanderson jasonlanderson added bug Something isn't working triage labels Jan 11, 2025
@jasonlanderson jasonlanderson changed the title dbt_utils.get_url_parameter will incorrectly match fields if they end with the field dbt_utils.get_url_parameter will incorrectly match fields if they end with url_parameter Jan 11, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working triage
Projects
None yet
Development

No branches or pull requests

1 participant