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

localhost:5443/settings An unhandled exception has occurred #29

Closed
LEIRONGHUA opened this issue Jan 30, 2023 · 8 comments
Closed

localhost:5443/settings An unhandled exception has occurred #29

LEIRONGHUA opened this issue Jan 30, 2023 · 8 comments
Labels
bug Something isn't working

Comments

@LEIRONGHUA
Copy link

Describe the bug
GET URL: https://localhost:5443/api/api/configuration/Aguacongas.TheIdServer.BlazorApp.Models.ServerConfig,%20Aguacongas.TheIdServer.BlazorApp.Infrastructure,%20Version=1.0.0.0,%20Culture=neutral,%20PublicKeyToken=null
image
image

Logs
System.InvalidOperationException: Failed to convert configuration value at 'TokenCleanupInterval' to type 'System.TimeSpan'.
---> System.FormatException: "00:05:00" is not a valid value for TimeSpan.
---> System.FormatException: String '"00:05:00"' was not recognized as a valid TimeSpan.
at System.Globalization.TimeSpanParse.TimeSpanResult.SetBadTimeSpanFailure()
at System.Globalization.TimeSpanParse.ProcessTerminal_HM_S_D(TimeSpanRawInfo& raw, TimeSpanStandardStyles style, TimeSpanResult& result)
at System.Globalization.TimeSpanParse.ProcessTerminalState(TimeSpanRawInfo& raw, TimeSpanStandardStyles style, TimeSpanResult& result)
at System.Globalization.TimeSpanParse.TryParseTimeSpan(ReadOnlySpan1 input, TimeSpanStandardStyles style, IFormatProvider formatProvider, TimeSpanResult& result) at System.TimeSpan.Parse(String input, IFormatProvider formatProvider) at System.ComponentModel.TimeSpanConverter.ConvertFrom(ITypeDescriptorContext context, CultureInfo culture, Object value) ......... at Microsoft.AspNetCore.Builder.EndpointRoutingApplicationBuilderExtensions.Authenticate(HttpContext context, Func1 next, String basePath, String authicationScheme) in D:\Work\SourceCode\Git\TheIdServer\src\IdentityServer\Duende\Aguacongas.IdentityServer.Admin.Duende\Extensions\EndpointRoutingApplicationBuilderExtensions.cs:line 138

Platform (please complete the following information):

  • OS: Windows 11 22H2(22621.1194)
  • .Net Core Version 7.0.102
@LEIRONGHUA LEIRONGHUA added the bug Something isn't working label Jan 30, 2023
@aguacongas
Copy link
Member

Hi, thx to contribute.
I don't reproduce, can you tell me what's your system's culture and in whitch format are serialized TimeSpan in this culture ?
The source code uses en-US.

@LEIRONGHUA
Copy link
Author

LEIRONGHUA commented Jan 31, 2023

Hi, thx to contribute. I don't reproduce, can you tell me what's your system's culture and in whitch format are serialized TimeSpan in this culture ? The source code uses en-US.

thank you for your reply.

System's culture
Console.WriteLine("CurrentCultureName is {0}.", System.Globalization.CultureInfo.CurrentCulture.Name);
//Print CurrentCultureName is zh-CN.

var timeSpan = TimeSpan.Parse("00:05:00");
Console.WriteLine("timeSpan is {0}.", timeSpan.ToString());
//Print timeSpan is 00:05:00

To Reproduce
Steps to reproduce the behavior:

  1. Go to 'https://localhost:5443/settings'
  2. Click on 'Save' (Do not modify any input, just click the save button)
  3. Refresh page
  4. See error

Here is the full error log
Error.log

I think that when saving, the value of the TokenCleanupInterval attribute 05:00:00 was saved as "00:05:00", with a pair of double quotation marks added.
As a result, an abnormal error occurred in the TimeSpan.Parse method

I'm very sorry, my English is not good, this is the sentence translated by Google

@aguacongas aguacongas transferred this issue from Aguafrommars/TheIdServer Jan 31, 2023
@aguacongas
Copy link
Member

@LEIRONGHUA I moved the issue in DynamicConfiguration because it's related to the Aguacongas.DynamicConfiguration.Redis lib.
To workaround you can delete Redis hash key by using redis-cli on your redis DB : hdel Aguacongas.TheIdServer.Duende TokenCleanupInterval

@LEIRONGHUA
Copy link
Author

LEIRONGHUA commented Feb 1, 2023

@aguacongas Thanks for the quick update.
I also found another problem: after I compile and publish, I still can't access the settings page normally. The error content is the same as the DEMO website.

Error Log

 blazor.webassembly.js:1 crit: Microsoft.AspNetCore.Components.WebAssembly.Rendering.WebAssemblyRenderer[100]
      Unhandled exception rendering component: DeserializeNoConstructor, JsonConstructorAttribute, Microsoft.AspNetCore.Identity.IdentityOptions Path: $.identityOptions | LineNumber: 0 | BytePositionInLine: 57.
System.NotSupportedException: DeserializeNoConstructor, JsonConstructorAttribute, Microsoft.AspNetCore.Identity.IdentityOptions Path: $.identityOptions | LineNumber: 0 | BytePositionInLine: 57.
 ---> System.NotSupportedException: DeserializeNoConstructor, JsonConstructorAttribute, Microsoft.AspNetCore.Identity.IdentityOptions
   Exception_EndOfInnerExceptionStack
   at System.Text.Json.Serialization.JsonConverter`1[[Aguacongas.TheIdServer.BlazorApp.Models.ServerConfig, Aguacongas.TheIdServer.BlazorApp.Infrastructure, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null]].ReadCore(Utf8JsonReader& , JsonSerializerOptions , ReadStack& )
   at System.Text.Json.JsonSerializer.ReadFromSpan[Object](ReadOnlySpan`1 , JsonTypeInfo )
   at Aguacongas.DynamicConfiguration.Razor.Services.ConfigurationService.GetConfigurationAsync(Type type, CancellationToken cancellationToken)
   at System.Text.Json.Serialization.JsonConverter`1[[Aguacongas.TheIdServer.BlazorApp.Models.ServerConfig, Aguacongas.TheIdServer.BlazorApp.Infrastructure, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null]].ReadCore(Utf8JsonReader& , JsonSerializerOptions , ReadStack& )
   at System.Text.Json.JsonSerializer.ReadFromSpan[Object](ReadOnlySpan`1 , JsonTypeInfo )
   at Aguacongas.DynamicConfiguration.Razor.Services.ConfigurationService.GetAsync(String key, CancellationToken cancellationToken)
   at System.Text.Json.Serialization.JsonConverter`1[[Aguacongas.TheIdServer.BlazorApp.Models.ServerConfig, Aguacongas.TheIdServer.BlazorApp.Infrastructure, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null]].ReadCore(Utf8JsonReader& , JsonSerializerOptions , ReadStack& )
   at System.Text.Json.JsonSerializer.ReadFromSpan[Object](ReadOnlySpan`1 , JsonTypeInfo )
   at Aguacongas.DynamicConfiguration.Razor.Settings.OnParametersSetAsync()
   at System.Text.Json.Serialization.JsonConverter`1[[Aguacongas.TheIdServer.BlazorApp.Models.ServerConfig, Aguacongas.TheIdServer.BlazorApp.Infrastructure, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null]].ReadCore(Utf8JsonReader& , JsonSerializerOptions , ReadStack& )
   at System.Text.Json.JsonSerializer.ReadFromSpan[Object](ReadOnlySpan`1 , JsonTypeInfo )
   at Microsoft.AspNetCore.Components.ComponentBase.CallStateHasChangedOnAsyncCompletion(Task task)
   at System.Text.Json.Serialization.JsonConverter`1[[Aguacongas.TheIdServer.BlazorApp.Models.ServerConfig, Aguacongas.TheIdServer.BlazorApp.Infrastructure, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null]].ReadCore(Utf8JsonReader& , JsonSerializerOptions , ReadStack& )
   at System.Text.Json.JsonSerializer.ReadFromSpan[Object](ReadOnlySpan`1 , JsonTypeInfo )
   at Microsoft.AspNetCore.Components.ComponentBase.RunInitAndSetParametersAsync()
   at System.Text.Json.Serialization.JsonConverter`1[[Aguacongas.TheIdServer.BlazorApp.Models.ServerConfig, Aguacongas.TheIdServer.BlazorApp.Infrastructure, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null]].ReadCore(Utf8JsonReader& , JsonSerializerOptions , ReadStack& )
   at System.Text.Json.JsonSerializer.ReadFromSpan[Object](ReadOnlySpan`1 , JsonTypeInfo )
   at Microsoft.AspNetCore.Components.RenderTree.Renderer.GetErrorHandledTask(Task , ComponentState )

Screenshot
image

To Reproduce
Steps to reproduce the behavior:

  1. Go to 'https://theidserver-duende.herokuapp.com/settings'
  2. F12 Open browser developer tools See error

thank you again for your dedication, offer my sincere respect.

@aguacongas
Copy link
Member

@LEIRONGHUA yes, it's because the value is stored into redis db, you need to delete it using redis-cli

@LEIRONGHUA
Copy link
Author

@aguacongas
Yes, Redis has been removed, and the problem with the 500 status has been resolved.
What I am reporting now is another BUG on the settings page.
Error in blazor.webassembly.js in browser
Please open the link to see: https://theidserver-duende.herokuapp.com/settings

@aguacongas
Copy link
Member

Ok, can you open a new bug at https://github.com/Aguafrommars/TheIdServer/issues please

@LEIRONGHUA
Copy link
Author

Ok, A new bug has been created: Aguafrommars/TheIdServer#944 (comment)

aguacongas pushed a commit that referenced this issue Feb 2, 2023
## [1.0.1](1.0.0...1.0.1) (2023-02-02)

### Bug Fixes

* cannot override configuration service ([ac04aa0](ac04aa0))
* failed to convert timespan ([0189bae](0189bae)), closes [#29](#29)
* sample/YarpSample/YarpServer/YarpServer.csproj to reduce vulnerabilities ([7d0534c](7d0534c))
* update packages ([3cfb1fa](3cfb1fa))
* update packages ([9169f72](9169f72))
* update packages ([f76b769](f76b769))
* update packages ([709de5e](709de5e))
* update packages ([a8a3a8f](a8a3a8f))
* update packages ([1ed38c5](1ed38c5))
* update packages ([da1abd1](da1abd1))
* update packages ([dc51845](dc51845))
* update packages ([b8531b3](b8531b3))
* update packages ([54801a3](54801a3))
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
Development

No branches or pull requests

2 participants