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 custom-header #369

Merged
merged 2 commits into from
Feb 2, 2022
Merged

Conversation

minrk
Copy link
Member

@minrk minrk commented Feb 2, 2022

collector must return the result

The test was passing because the update-in-place way we implemented the collector apparently works if you have more than one header, but not if you have only one. I don't know if that's a bug upstream or not, but the right thing to do is to return after each collection.

Additional improvements:

  • allow colons in header values (split only on first, since colons are quite sensible in header values, e.g. host:port)
  • log and exit when proxy cli fails to start in tests

closes #368

collector must return the result

it's unclear why the test passed, when running the same code by hand did

- allow colons in header values (split only on first)
- log and exit when proxy cli fails to start in tests
@minrk minrk force-pushed the return-custom-header branch from 16736b4 to 807dda7 Compare February 2, 2022 08:37
@minrk minrk requested a review from consideRatio February 2, 2022 08:38
Copy link

@Timost Timost left a comment

Choose a reason for hiding this comment

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

Thank you for these changes ! 🙏 🙏

Just a small doubt around the log.error call in collectHeadersIntoObject

value = value.trim();
var colon = value.indexOf(":");
if (colon <= 0) {
log.error("A colon was expected in custom header: " + value);
Copy link

Choose a reason for hiding this comment

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

I think calling log here isn't valid. I got crashes when fidling with this part of the code to make it log using log.

Copy link
Member Author

Choose a reason for hiding this comment

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

Good catch! Fixed and test added.

@@ -229,7 +240,7 @@ describe("CLI Tests", function () {
"--custom-header",
"k1: v1",
"--custom-header",
" k2 : v2 v2 ",
" k2 : host:123 ",
Copy link

Choose a reason for hiding this comment

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

Maybe adding a test with an invalid header (eg --custom-header badheader) would be worthwile ? I think the current error logging in collectHeadersIntoObject crashes.

and fix undefined `log.error` in favor of `console.error`
Copy link
Member

@consideRatio consideRatio left a comment

Choose a reason for hiding this comment

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

Wieee nice work @minrk and thank you @Timost for helping out with the review effort 🎉 🚀 ❤️!! This LGTM, great review points @Timost!

If this looks good to @Timost, let's merge!

@Timost
Copy link

Timost commented Feb 2, 2022

LGTM ! Thank you for doing all the work ! 🙏

@consideRatio consideRatio merged commit c449ccb into jupyterhub:main Feb 2, 2022
@minrk minrk deleted the return-custom-header branch February 3, 2022 08:24
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.

--custom-header option doesn't work with only one header
3 participants