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

monograph: probability of failure when publishing a monograph #6991

Closed
dyw770 opened this issue Nov 25, 2024 · 2 comments
Closed

monograph: probability of failure when publishing a monograph #6991

dyw770 opened this issue Nov 25, 2024 · 2 comments

Comments

@dyw770
Copy link
Contributor

dyw770 commented Nov 25, 2024

Some people have encountered the issue of publishing monograph failing. #6982 and streetwriters/notesnook-sync-server#17

notesnook sync server log as follows:

Connection id "0HN7ARI31RBA4", Request id "0HN7ARI31RBA4:0000002C": An unhandled exception was thrown by the application.
System.FormatException: '674356b1503ec39a344ea2b' is not a valid 24 digit hex string.
   at Streetwriters.Data.Repositories.Repository`1.GetAsync(String id)
   at Notesnook.API.Controllers.MonographsController.PublishAsync(Monograph monograph) in /src/Notesnook.API/Controllers/MonographsController.cs:line 54
   at Microsoft.AspNetCore.Mvc.Infrastructure.ActionMethodExecutor.TaskOfIActionResultExecutor.Execute(ActionContext actionContext, IActionResultTypeMapper mapper, ObjectMethodExecutor executor, Object controller, Object[] arguments)
   at Microsoft.AspNetCore.Mvc.Infrastructure.ControllerActionInvoker.<InvokeActionMethodAsync>g__Awaited|12_0(ControllerActionInvoker invoker, ValueTask`1 actionResultValueTask)
   at Microsoft.AspNetCore.Mvc.Infrastructure.ControllerActionInvoker.<InvokeNextActionFilterAsync>g__Awaited|10_0(ControllerActionInvoker invoker, Task lastTask, State next, Scope scope, Object state, Boolean isCompleted)
   at Microsoft.AspNetCore.Mvc.Infrastructure.ControllerActionInvoker.Rethrow(ActionExecutedContextSealed context)
   at Microsoft.AspNetCore.Mvc.Infrastructure.ControllerActionInvoker.Next(State& next, Scope& scope, Object& state, Boolean& isCompleted)
   at Microsoft.AspNetCore.Mvc.Infrastructure.ControllerActionInvoker.InvokeInnerFilterAsync()
--- End of stack trace from previous location ---
   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__Awaited|17_0(ResourceInvoker invoker, Task task, IDisposable scope)
   at Microsoft.AspNetCore.Mvc.Infrastructure.ResourceInvoker.<InvokeAsync>g__Awaited|17_0(ResourceInvoker invoker, Task task, IDisposable scope)
   at Notesnook.API.Extensions.AuthorizationResultTransformer.HandleAsync(RequestDelegate requestDelegate, HttpContext httpContext, AuthorizationPolicy authorizationPolicy, PolicyAuthorizationResult policyAuthorizationResult) in /src/Notesnook.API/Extensions/AuthorizationResultTransformer.cs:line 67
   at Microsoft.AspNetCore.Authorization.AuthorizationMiddleware.Invoke(HttpContext context)
   at Microsoft.AspNetCore.Authentication.AuthenticationMiddleware.Invoke(HttpContext context)
   at Microsoft.AspNetCore.ResponseCompression.ResponseCompressionMiddleware.InvokeCore(HttpContext)
   at Microsoft.AspNetCore.Server.Kestrel.Core.Internal.Http.HttpProtocol.ProcessRequests[TContext](IHttpApplication`1)

After testing, I found that the creatObjectid method occasionally returns an ID of less than 24.

const MACHINE_ID = Math.floor(Math.random() * 0xffffff);
const pid = Math.floor(Math.random() * 100000) % 0xffff;
let index = Math.floor(Math.random() * 0xffffff);
const PROCESS_UNIQUE = MACHINE_ID.toString(16) + pid.toString(16);

You seem to have forgotten to fill the PROCESS_UNIQUE variable with sufficient length. Can you fix this problem? Because I am not sure if directly modifying this method will affect other areas. Of course, if you are willing, I would also be happy to submit a PR.

@dyw770
Copy link
Contributor Author

dyw770 commented Nov 25, 2024

@thecodrr

@thecodrr
Copy link
Contributor

@dyw770 feel free to open a PR!

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

No branches or pull requests

2 participants