Skip to content

fix: fix --header flag in CLI #8023

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

Merged
merged 1 commit into from
Jun 14, 2023
Merged

fix: fix --header flag in CLI #8023

merged 1 commit into from
Jun 14, 2023

Conversation

deansheather
Copy link
Member

@deansheather deansheather commented Jun 14, 2023

The --header flag was changed from key=value to key:value in 43eee35 which is a breaking change.

This PR reverts the behavior to key=value as there doesn't seem to be a good reason for the breaking change.

The ExtraHeaders field is removed from codersdk.Client to match the prior behavior and to reduce the amount of ways headers can be set in the SDK to avoid confusion.

This regression would've been caught by an existing test, but the test was faulty and didn't catch the issue. The test has been fixed and improved, and a test has been added to make sure headers are sent to the DERP server to avoid breaking #6572.

Fixes #8021
Fixes https://github.com/coder/v2-customers/issues/203

@deansheather deansheather requested review from mafredri and ammario June 14, 2023 10:38
@deansheather deansheather self-assigned this Jun 14, 2023
@@ -430,6 +427,15 @@ type RootCmd struct {
}

func addTelemetryHeader(client *codersdk.Client, inv *clibase.Invocation) {
transport, ok := client.HTTPClient.Transport.(*headerTransport)
if !ok {
transport = &headerTransport{
Copy link
Member

Choose a reason for hiding this comment

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

I'm a bit worried about losing headers in a situation where we think it's safe to wrap the transport and we end up with a type that's headerTransport(otherTransport(headerTransport)). Not sure what the best approach to guard against this would be, though.

Copy link
Member Author

Choose a reason for hiding this comment

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

Yeah I'm unsure either but I don't think it will happen in practice, the addTelemetryHeader fn is called immediately after creating the client

Copy link
Member

@ammario ammario Jun 15, 2023

Choose a reason for hiding this comment

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

The original issue 43eee35 was attempting to solve is scaletests were replacing the HTTP Transport, and with that losing custom headers. I discovered this by noticing that we weren't receiving telemetry for scaletest commands.

#8054

@deansheather deansheather merged commit 2c843f4 into main Jun 14, 2023
@deansheather deansheather deleted the dean/fix-headers branch June 14, 2023 11:52
@github-actions github-actions bot locked and limited conversation to collaborators Jun 14, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

--header format changed in recent version, must be colon delimited now
4 participants