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

Commands fail with scheme being empty #286

Closed
jakubgs opened this issue Apr 7, 2020 · 5 comments
Closed

Commands fail with scheme being empty #286

jakubgs opened this issue Apr 7, 2020 · 5 comments
Labels

Comments

@jakubgs
Copy link

jakubgs commented Apr 7, 2020

I'm trying to use the docker image but it's failing with weird errors I don't understand:

 $ docker run --rm -it -e TOKEN="MY_TOKEN" tyrrrz/discordchatexporter channels --token $TOKEN --guild 1234567890
System.ArgumentException: The value cannot be null or empty. (Parameter 'scheme')
   at System.Net.Http.Headers.HeaderUtilities.CheckValidToken(String value, String parameterName)
   at System.Net.Http.Headers.AuthenticationHeaderValue..ctor(String scheme, String parameter)
   at System.Net.Http.Headers.AuthenticationHeaderValue..ctor(String scheme)
   at DiscordChatExporter.Core.Services.DataService.<>c__DisplayClass4_0.<<GetApiResponseAsync>b__0>d.MoveNext() in /src/DiscordChatExporter.Core.Services/DataService.cs:line 55
--- End of stack trace from previous location where exception was thrown ---
   at Polly.Retry.AsyncRetryEngine.ImplementationAsync[TResult](Func`3 action, Context context, CancellationToken cancellationToken, ExceptionPredicates shouldRetryExceptionPredicates, ResultPredicates`1 shouldRetryResultPredicates, Func`5 onRetryAsync, Int32 permittedRetryCount, IEnumerable`1 sleepDurationsEnumerable, Func`4 sleepDurationProvider, Boolean continueOnCapturedContext)
   at Polly.AsyncPolicy`1.ExecuteAsync(Func`3 action, Context context, CancellationToken cancellationToken, Boolean continueOnCapturedContext)
   at DiscordChatExporter.Core.Services.DataService.GetApiResponseAsync(AuthToken token, String route, Boolean errorOnFail) in /src/DiscordChatExporter.Core.Services/DataService.cs:line 51
   at DiscordChatExporter.Core.Services.DataService.GetApiResponseAsync(AuthToken token, String route) in /src/DiscordChatExporter.Core.Services/DataService.cs:line 46
   at DiscordChatExporter.Core.Services.DataService.GetGuildChannelsAsync(AuthToken token, String guildId) in /src/DiscordChatExporter.Core.Services/DataService.cs:line 140
   at DiscordChatExporter.Cli.Commands.GetChannelsCommand.ExecuteAsync(IConsole console) in /src/DiscordChatExporter.Cli/Commands/GetChannelsCommand.cs:line 23
   at CliFx.CliApplication.HandleCommandExecutionAsync(ApplicationSchema applicationSchema, CommandLineInput commandLineInput, IReadOnlyDictionary`2 environmentVariables)
   at CliFx.CliApplication.RunAsync(IReadOnlyList`1 commandLineArguments, IReadOnlyDictionary`2 environmentVariables)

What does this mean?

@Tyrrrz
Copy link
Owner

Tyrrrz commented Apr 7, 2020

Looks like token being passed is null. Are you sure $TOKEN retrieves the value you expect it to?

@Tyrrrz
Copy link
Owner

Tyrrrz commented Apr 7, 2020

I reproduced the exact issue you have with the snippet you gave me, but if I change $TOKEN to the literal value of my token then it works correctly.

@Tyrrrz
Copy link
Owner

Tyrrrz commented Apr 7, 2020

Note that -e ... sets an environment variable inside the container, while $TOKEN tries to read it from the current environment, i.e. the host machine (I'm pretty sure).

@Tyrrrz Tyrrrz added the invalid label Apr 7, 2020
@jakubgs
Copy link
Author

jakubgs commented Apr 7, 2020

Oh, you're right. I misunderstood how to handle the env variables in Docker commands.

But wouldn't it make sense to add a check that verifies if an input like token is not an empty string?

@Tyrrrz
Copy link
Owner

Tyrrrz commented Apr 7, 2020

It would, yeah.
I created a separate issue for it Tyrrrz/CliFx#47

@Tyrrrz Tyrrrz closed this as completed Apr 7, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants