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

Revert "Move more model classes to records" #119

Closed
wants to merge 1 commit into from

Conversation

jonashendrickx
Copy link
Member

@jonashendrickx jonashendrickx commented Feb 25, 2024

Reverts #108. See pull request description on bitwarden/passwordless-server#434

Copy link

codecov bot commented Feb 25, 2024

Codecov Report

Attention: Patch coverage is 34.69388% with 32 lines in your changes are missing coverage. Please review.

Project coverage is 60.22%. Comparing base (854d3e5) to head (0aa117b).

Files Patch % Lines
src/Passwordless/Models/Credential.cs 0.00% 20 Missing ⚠️
src/Passwordless/Models/ApplicationEvent.cs 0.00% 7 Missing ⚠️
src/Passwordless/Models/SetAliasRequest.cs 0.00% 5 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main     #119      +/-   ##
==========================================
+ Coverage   60.19%   60.22%   +0.03%     
==========================================
  Files          41       41              
  Lines         613      616       +3     
  Branches       53       54       +1     
==========================================
+ Hits          369      371       +2     
  Misses        239      239              
- Partials        5        6       +1     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@abergs
Copy link
Member

abergs commented Feb 26, 2024

That description only contained the exception below. Could you please add a bit more context to what the issue is and what steps we should take to move forward, and any side-effects reversing would cause.

@Tyrrrz This feels like your area to investigate as well.

[13:02:44 ERR] HTTP GET /app/app1/credentials/user/102a8297-5704-41bf-b91d-e1f2e858ee75 responded 500 in 288.9540 ms
System.InvalidOperationException: Deserialization of init-only properties is currently not supported in source generation mode.
   at Passwordless.Helpers.PasswordlessSerializerContext.<>c.<CredentialPropInit>b__158_29(Object obj, Nullable`1 value) in /_/src/Passwordless/System.Text.Json.SourceGeneration/System.Text.Json.SourceGeneration.JsonSourceGenerator/PasswordlessSerializerContext.Credential.g.cs:line 365
   at System.Text.Json.Serialization.Metadata.JsonPropertyInfo`1.<>c__DisplayClass10_0.<SetSetter>b__0(Object obj, Object value)
   at System.Text.Json.Serialization.Converters.ObjectWithParameterizedConstructorConverter`1.OnTryRead(Utf8JsonReader& reader, Type typeToConvert, JsonSerializerOptions options, ReadStack& state, T& value)
   at System.Text.Json.Serialization.JsonConverter`1.TryRead(Utf8JsonReader& reader, Type typeToConvert, JsonSerializerOptions options, ReadStack& state, T& value, Boolean& isPopulatedValue)
   at System.Text.Json.Serialization.JsonCollectionConverter`2.OnTryRead(Utf8JsonReader& reader, Type typeToConvert, JsonSerializerOptions options, ReadStack& state, TCollection& value)
   at System.Text.Json.Serialization.JsonConverter`1.TryRead(Utf8JsonReader& reader, Type typeToConvert, JsonSerializerOptions options, ReadStack& state, T& value, Boolean& isPopulatedValue)
   at System.Text.Json.Serialization.JsonConverter`1.TryReadAsObject(Utf8JsonReader& reader, Type typeToConvert, JsonSerializerOptions options, ReadStack& state, Object& value)
   at System.Text.Json.Serialization.Converters.LargeObjectWithParameterizedConstructorConverter`1.ReadAndCacheConstructorArgument(ReadStack& state, Utf8JsonReader& reader, JsonParameterInfo jsonParameterInfo)
   at System.Text.Json.Serialization.Converters.ObjectWithParameterizedConstructorConverter`1.ReadConstructorArgumentsWithContinuation(ReadStack& state, Utf8JsonReader& reader, JsonSerializerOptions options)
   at System.Text.Json.Serialization.Converters.ObjectWithParameterizedConstructorConverter`1.OnTryRead(Utf8JsonReader& reader, Type typeToConvert, JsonSerializerOptions options, ReadStack& state, T& value)
   at System.Text.Json.Serialization.JsonConverter`1.TryRead(Utf8JsonReader& reader, Type typeToConvert, JsonSerializerOptions options, ReadStack& state, T& value, Boolean& isPopulatedValue)
   at System.Text.Json.Serialization.JsonConverter`1.ReadCore(Utf8JsonReader& reader, JsonSerializerOptions options, ReadStack& state)
   at System.Text.Json.Serialization.Metadata.JsonTypeInfo`1.ContinueDeserialize(ReadBufferState& bufferState, JsonReaderState& jsonReaderState, ReadStack& readStack)
   at System.Text.Json.Serialization.Metadata.JsonTypeInfo`1.DeserializeAsync(Stream utf8Json, CancellationToken cancellationToken)
   at System.Net.Http.Json.HttpClientJsonExtensions.<FromJsonAsyncCore>g__Core|12_0[TValue,TJsonOptions](HttpClient client, Task`1 responseTask, Boolean usingResponseHeadersRead, CancellationTokenSource linkedCTS, Func`4 deserializeMethod, TJsonOptions jsonOptions, CancellationToken cancellationToken)
   at Passwordless.PasswordlessClient.ListCredentialsAsync(String userId, CancellationToken cancellationToken) in /_/src/Passwordless/PasswordlessClient.cs:line 182
   at Passwordless.AdminConsole.Pages.App.Credentials.UserModel.OnGet() in /Users/jonashendrickx/src/bitwarden/passwordless-server/src/AdminConsole/Pages/App/Credentials/User.cshtml.cs:line 32
   at Microsoft.AspNetCore.Mvc.RazorPages.Infrastructure.ExecutorFactory.NonGenericTaskHandlerMethod.Execute(Object receiver, Object[] arguments)
   at Microsoft.AspNetCore.Mvc.RazorPages.Infrastructure.PageActionInvoker.InvokeHandlerMethodAsync()
   at Microsoft.AspNetCore.Mvc.RazorPages.Infrastructure.PageActionInvoker.InvokeNextPageFilterAsync()
   at Microsoft.AspNetCore.Mvc.RazorPages.Infrastructure.PageActionInvoker.Rethrow(PageHandlerExecutedContext context)
   at Microsoft.AspNetCore.Mvc.RazorPages.Infrastructure.PageActionInvoker.Next(State& next, Scope& scope, Object& state, Boolean& isCompleted)
   at Microsoft.AspNetCore.Mvc.RazorPages.Infrastructure.PageActionInvoker.InvokeInnerFilterAsync()
   at Microsoft.AspNetCore.Mvc.Infrastructure.ResourceInvoker.<InvokeNextResourceFilter>g__Awaited|25_0(ResourceInvoker invoker, Task lastTask, State next, Scope scope, Object state, Boolean isCompleted)
   at Microsoft.AspNetCore.Mvc.Infrastructure.ResourceInvoker.Rethrow(ResourceExecutedContextSealed context)
   at Microsoft.AspNetCore.Mvc.Infrastructure.ResourceInvoker.Next(State& next, Scope& scope, Object& state, Boolean& isCompleted)
   at Microsoft.AspNetCore.Mvc.Infrastructure.ResourceInvoker.<InvokeFilterPipelineAsync>g__Awaited|20_0(ResourceInvoker invoker, Task lastTask, State next, Scope scope, Object state, Boolean isCompleted)
   at Microsoft.AspNetCore.Mvc.Infrastructure.ResourceInvoker.<InvokeAsync>g__Logged|17_1(ResourceInvoker invoker)
   at Microsoft.AspNetCore.Mvc.Infrastructure.ResourceInvoker.<InvokeAsync>g__Logged|17_1(ResourceInvoker invoker)
   at Microsoft.AspNetCore.Authorization.AuthorizationMiddleware.Invoke(HttpContext context)
   at Passwordless.AdminConsole.Middleware.EventLogStorageCommitMiddleware.InvokeAsync(HttpContext context, IEventLogger eventLogger) in /Users/jonashendrickx/src/bitwarden/passwordless-server/src/AdminConsole/Middleware/EventLogStorageCommitMiddleware.cs:line 22
   at Passwordless.AdminConsole.Middleware.EventLogStorageCommitMiddleware.InvokeAsync(HttpContext context, IEventLogger eventLogger) in /Users/jonashendrickx/src/bitwarden/passwordless-server/src/AdminConsole/Middleware/EventLogStorageCommitMiddleware.cs:line 27
   at Passwordless.AdminConsole.Middleware.CurrentContextMiddleware.InvokeCoreAsync(HttpContext httpContext, String appId, ICurrentContext currentContext, IDataService dataService, IPasswordlessManagementClient passwordlessClient, IOrganizationFeatureService organizationFeatureService) in /Users/jonashendrickx/src/bitwarden/passwordless-server/src/AdminConsole/Middleware/CurrentContextMiddleware.cs:line 84
   at Microsoft.AspNetCore.Authentication.AuthenticationMiddleware.Invoke(HttpContext context)
   at Serilog.AspNetCore.RequestLoggingMiddleware.Invoke(HttpContext httpContext)
[13:02:44 ERR] An unhandled exception has occurred while executing the request.
System.InvalidOperationException: Deserialization of init-only properties is currently not supported in source generation mode.
   at Passwordless.Helpers.PasswordlessSerializerContext.<>c.<CredentialPropInit>b__158_29(Object obj, Nullable`1 value) in /_/src/Passwordless/System.Text.Json.SourceGeneration/System.Text.Json.SourceGeneration.JsonSourceGenerator/PasswordlessSerializerContext.Credential.g.cs:line 365

@jonashendrickx
Copy link
Member Author

System.InvalidOperationException: Deserialization of init-only properties is currently not supported in source generation mode.

All the information you need is in the stack trace. Records create init-only properties. But if you use a source generator, it won't work. See: https://github.com/bitwarden/passwordless-dotnet/blob/main/src/Passwordless/Helpers/PasswordlessSerializerContext.cs

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

Successfully merging this pull request may close these issues.

2 participants