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

Avoid raising errors on database passwords that contain a $ character #14876

Merged
merged 2 commits into from
Aug 12, 2024

Conversation

desertaxle
Copy link
Member

@desertaxle desertaxle commented Aug 9, 2024

This PR fixes errors raised when a database password contains a $ character by using safe_substitute when templating. Templating will not occur when a $ character is present in the password, which means that errors may still occur with settings like the following:

PREFECT_API_DATABASE_NAME="the-database"
PREFECT_API_DATABASE_CONNECTION_URL="postgresql+asyncpg://the-user:the-$password@localhost:5432/${PREFECT_API_DATABASE_NAME}"

Since this setup would fail without these changes, and the docs recommend setting PREFECT_API_DATABASE_CONNECTION_URL directly, I think this behavior is acceptable.

Closes #11067

Checklist

  • This pull request references any related issue by including "closes <link to issue>"
    • If no issue exists and your change is not a small fix, please create an issue first.
  • If this pull request adds new functionality, it includes unit tests that cover the changes
  • If this pull request removes docs files, it includes redirect settings in mint.json.
  • If this pull request adds functions or classes, it includes helpful docstrings.

@desertaxle desertaxle requested a review from cicdw as a code owner August 9, 2024 21:29
Copy link

codspeed-hq bot commented Aug 9, 2024

CodSpeed Performance Report

Merging #14876 will not alter performance

Comparing fix-dbconnection-string-templating (3f7d100) with main (1259703)

Summary

✅ 4 untouched benchmarks

Copy link
Member

@cicdw cicdw left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Makes sense - I think we can eventually find a way to support both $ characters and variable expansion in the same setting, but given that this implementation is a strict improvement we can consider that in the future.

Copy link
Collaborator

@zzstoatzz zzstoatzz left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

lgtm!

@desertaxle desertaxle merged commit 8f04edb into main Aug 12, 2024
30 checks passed
@desertaxle desertaxle deleted the fix-dbconnection-string-templating branch August 12, 2024 13:28
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
3 participants