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

get_url_parameter does not work for small parameters that are included in other params #884

Closed
1 of 5 tasks
Stephen986 opened this issue Apr 18, 2024 · 4 comments
Closed
1 of 5 tasks
Labels
bug Something isn't working Stale triage

Comments

@Stephen986
Copy link

Stephen986 commented Apr 18, 2024

Describe the bug

The get_url_parameter generally works for long parameters, but if it's a small param that could be included in other parameters, it will not work properly. While UTMs are the most common types of URL parameters, I've worked with companies that those &c, &e, and other tiny parameters in them that doesn't work with this macro.

Steps to reproduce

Use get_url_parameter on a URL where the characters of one parameter is also inside another parameter, such as:

select {{ dbt_utils.get_url_parameter(field='page_url', url_parameter='ce') }} 
where page_url = 'https://www.dbt.com?utm_source=github'

Expected results

In the above example, I would expect the macro to not return a parameter, because it doesn't have &ce or ?ce in it.

Actual results

The macro would return github as the 'ce' parameter.

Screenshots and log output

System information

The contents of your packages.yml file:

Which database are you using dbt with?

  • postgres
  • redshift
  • bigquery
  • snowflake
  • other (specify: ____________)

The output of dbt --version:

<output goes here>

Additional context

Are you interested in contributing the fix?

@Stephen986 Stephen986 added bug Something isn't working triage labels Apr 18, 2024
@Stephen986
Copy link
Author

Stephen986 commented Apr 19, 2024

The solution I ended up using was to coalesce a split part of ?param= and a split part of &param= together. That way it works for either of those situations, but it's not triggered by the param being at the end of another param.

I can submit a PR for that if everyone likes that solution? It's ugly, but it works for all the use cases I deal with.

@dbeatty10
Copy link
Contributor

Thanks for raising this issue @Stephen986!

If you raise a PR with the solution you used, I can take a look at it.

Copy link

This issue has been marked as Stale because it has been open for 180 days with no activity. If you would like the issue to remain open, please comment on the issue or else it will be closed in 7 days.

@github-actions github-actions bot added the Stale label Nov 10, 2024
Copy link

Although we are closing this issue as stale, it's not gone forever. Issues can be reopened if there is renewed community interest. Just add a comment to notify the maintainers.

@github-actions github-actions bot closed this as not planned Won't fix, can't repro, duplicate, stale Nov 17, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working Stale triage
Projects
None yet
Development

No branches or pull requests

2 participants