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

Fix double formatting of callables (command, environment, request_headers_override) #437

Merged
merged 2 commits into from
Jan 4, 2024

Conversation

diocas
Copy link
Contributor

@diocas diocas commented Dec 7, 2023

If a server has a callable as the environment, jupyter-server-proxy formatted it twice.

If that callable returned an escaped var (i.e. { "MYVAR": "{{var}}" }), the server was crashing when doing the second formatting (as "var" does not exist).

>>> myVar = "{{var}}"
>>> myVar = myVar.format({})
>>> myVar = myVar.format({})
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
KeyError: 'var'

With this PR I only format once, wether it's callable or dict.

If the environment has an escaped variable (so, a string), the server should start without failing to format it.
It was doing double formatting, which broke when passing environment variables with escaped strings (i.e {{var}}).
Copy link

welcome bot commented Dec 7, 2023

Thanks for submitting your first pull request! You are awesome! 🤗

If you haven't done so already, check out Jupyter's Code of Conduct.
welcome
You can meet the other Jovyans by joining our Discourse forum. There is also a intro thread there where you can stop by and say Hi! 👋

Welcome to the Jupyter community! 🎉

etejedor added a commit to etejedor/jupyter-images that referenced this pull request Dec 8, 2023
To prevent double formatting of environment variables.

See PR upstream:
jupyterhub/jupyter-server-proxy#437
etejedor added a commit to etejedor/jupyter-images that referenced this pull request Dec 8, 2023
To prevent double formatting of environment variables.

See PR upstream:
jupyterhub/jupyter-server-proxy#437
etejedor added a commit to swan-cern/jupyter-images that referenced this pull request Dec 8, 2023
To prevent double formatting of environment variables.

See PR upstream:
jupyterhub/jupyter-server-proxy#437
@consideRatio consideRatio changed the title Prevent double formatting of env variables Fix double formatting of callables (command, environment, request_headers_override) Jan 4, 2024
@consideRatio
Copy link
Member

I saw that this was a bug for command, environment, and request_headers_override, so I updated the PR title to reflect that.

Thank you @diocas for the thorough work fixing this with a description and a test!! ❤️ 🎉 🌻

@consideRatio consideRatio merged commit 98eff01 into jupyterhub:main Jan 4, 2024
11 checks passed
Copy link

welcome bot commented Jan 4, 2024

Congrats on your first merged pull request in this project! 🎉
congrats
Thank you for contributing, we are very proud of you! ❤️

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants