const uploadResponse = await request.post(`/api/Worlds`, {
headers: { 'token': apiToken },
multipart: {
backupFile: {
name: 'testwelt.mbz',
mimeType: 'application/octet-stream',
buffer: fs.readFileSync(path.join(__dirname, 'fixtures', 'testwelt.mbz'))
},
atfFile: {
name: 'testwelt.awf',
mimeType: 'application/json',
buffer: fs.readFileSync(path.join(__dirname, 'fixtures', 'testwelt.awf'))
}
}
});
results in the error below. Issue is the wrong file was uploaded as atf file (was a xml file)
backend-1 | 2025-01-27 20:20:03.828 +00:00 [ERR] An unknown error occurred while processing the request
backend-1 | System.Text.Json.JsonException: '<' is an invalid start of a value. Path: $ | LineNumber: 0 | BytePositionInLine: 0.
backend-1 | ---> System.Text.Json.JsonReaderException: '<' is an invalid start of a value. LineNumber: 0 | BytePositionInLine: 0.
backend-1 | at System.Text.Json.ThrowHelper.ThrowJsonReaderException(Utf8JsonReader& json, ExceptionResource resource, Byte nextByte, ReadOnlySpan`1 bytes)
backend-1 | at System.Text.Json.Utf8JsonReader.ConsumeValue(Byte marker)
backend-1 | at System.Text.Json.Utf8JsonReader.ReadFirstToken(Byte first)
backend-1 | at System.Text.Json.Utf8JsonReader.ReadSingleSegment()
backend-1 | at System.Text.Json.Serialization.JsonConverter`1.ReadCore(Utf8JsonReader& reader, JsonSerializerOptions options, ReadStack& state)
backend-1 | --- End of inner exception stack trace ---
backend-1 | at System.Text.Json.ThrowHelper.ReThrowWithPath(ReadStack& state, JsonReaderException ex)
backend-1 | at System.Text.Json.Serialization.JsonConverter`1.ReadCore(Utf8JsonReader& reader, JsonSerializerOptions options, ReadStack& state)
backend-1 | at System.Text.Json.Serialization.Metadata.JsonTypeInfo`1.ContinueDeserialize(ReadBufferState& bufferState, JsonReaderState& jsonReaderState, ReadStack& readStack)
backend-1 | at System.Text.Json.Serialization.Metadata.JsonTypeInfo`1.Deserialize(Stream utf8Json)
backend-1 | at AdLerBackend.Infrastructure.LmsBackup.LmsBackupProcessor.GetWorldDescriptionFromBackup(Stream atfStream) in /src/AdLerBackend.Infrastructure/LmsBackup/LmsBackupProcessor.cs:line 33
backend-1 | at AdLerBackend.Application.World.WorldManagement.UploadWorld.UploadWorldUseCase.Handle(UploadWorldCommand request, CancellationToken cancellationToken) in /src/AdLerBackend.Application/World/WorldManagement/UploadWorld/UploadWorldUseCase.cs:line 40
backend-1 | at AdLerBackend.Application.World.WorldManagement.UploadWorld.UploadWorldUseCase.Handle(UploadWorldCommand request, CancellationToken cancellationToken) in /src/AdLerBackend.Application/World/WorldManagement/UploadWorld/UploadWorldUseCase.cs:line 68
backend-1 | at AdLerBackend.Application.Common.Behaviours.LoggingBehavior`2.Handle(TRequest request, RequestHandlerDelegate`1 next, CancellationToken cancellationToken)
backend-1 | at AdLerBackend.Application.Common.Behaviours.ValidationBehaviour`2.Handle(TRequest request, RequestHandlerDelegate`1 next, CancellationToken cancellationToken)
backend-1 | at MediatR.Pipeline.RequestExceptionProcessorBehavior`2.Handle(TRequest request, RequestHandlerDelegate`1 next, CancellationToken cancellationToken)
backend-1 | at MediatR.Pipeline.RequestExceptionProcessorBehavior`2.Handle(TRequest request, RequestHandlerDelegate`1 next, CancellationToken cancellationToken)
backend-1 | at AdLerBackend.API.Controllers.Worlds.WorldsController.CreateWorld(IFormFile backupFile, IFormFile atfFile, String token) in /src/AdLerBackend.API/Controllers/Worlds/WorldsController.cs:line 80
backend-1 | at lambda_method42(Closure, Object)
backend-1 | at Microsoft.AspNetCore.Mvc.Infrastructure.ActionMethodExecutor.AwaitableObjectResultExecutor.Execute(ActionContext actionContext, IActionResultTypeMapper mapper, ObjectMethodExecutor executor, Object controller, Object[] arguments)
backend-1 | at Microsoft.AspNetCore.Mvc.Infrastructure.ControllerActionInvoker.<InvokeActionMethodAsync>g__Awaited|12_0(ControllerActionInvoker invoker, ValueTask`1 actionResultValueTask)
backend-1 | at Microsoft.AspNetCore.Mvc.Infrastructure.ControllerActionInvoker.<InvokeNextActionFilterAsync>g__Awaited|10_0(ControllerActionInvoker invoker, Task lastTask, State next, Scope scope, Object state, Boolean isCompleted)
backend-1 | at Microsoft.AspNetCore.Mvc.Infrastructure.ControllerActionInvoker.Rethrow(ActionExecutedContextSealed context)
backend-1 | at Microsoft.AspNetCore.Mvc.Infrastructure.ControllerActionInvoker.Next(State& next, Scope& scope, Object& state, Boolean& isCompleted)
backend-1 | at Microsoft.AspNetCore.Mvc.Infrastructure.ControllerActionInvoker.<InvokeInnerFilterAsync>g__Awaited|13_0(ControllerActionInvoker invoker, Task lastTask, State next, Scope scope, Object state, Boolean isCompleted)
backend-1 | at Microsoft.AspNetCore.Mvc.Infrastructure.ResourceInvoker.<InvokeNextExceptionFilterAsync>g__Awaited|26_0(ResourceInvoker invoker, Task lastTask, State next, Scope scope, Object state, Boolean isCompleted)
This test code
results in the error below. Issue is the wrong file was uploaded as atf file (was a xml file)