Azure / Azure/data-api-builder

[Bug]: JSON data in POST request is handled as text

Aperta
#2,817 0 commenti 1 reazione 0 assegnatari Vedi su GitHub
bug cri pgsql triage
Lingua principale
C#
Stelle
1.5k
Fork
370
Merge medio
3g 22h
PR unite (30g)
9

Descrizione

### What happened?

When doing a POST request that includes data that should be put in a JSON column (in PostgreSQL), it is handled as text and the insert fails.

Image

I expected the value to be inserted into the database.

### Version

1.5.56+61c726a0fc38ab5a1d9e52cc3593bbd2a8633aec

### What database are you using?

PostgreSQL

### What hosting model are you using?

Custom Docker host

### Which API approach are you accessing DAB through?

REST

### Relevant log output

```Text
fail: Azure.DataApiBuilder.Service.Controllers.RestController[0]

f3eefcf8-c1ce-47c2-9e21-d9d748e421d7 Error handling REST request.

Azure.DataApiBuilder.Service.Exceptions.DataApiBuilderException: 42804: column "u_response" is of type json but expression is of type text

POSITION: 62

---> Npgsql.PostgresException (0x80004005): 42804: column "u_response" is of type json but expression is of type text

POSITION: 62

at Npgsql.Internal.NpgsqlConnector.ReadMessageLong(Boolean async, DataRowLoadingMode dataRowLoadingMode, Boolean readingNotifications, Boolean isReadingPrependedMessage)

at System.Runtime.CompilerServices.PoolingAsyncValueTaskMethodBuilder`1.StateMachineBox`1.System.Threading.Tasks.Sources.IValueTaskSource.GetResult(Int16 token)

at Npgsql.NpgsqlDataReader.NextResult(Boolean async, Boolean isConsuming, CancellationToken cancellationToken)

at Npgsql.NpgsqlDataReader.NextResult(Boolean async, Boolean isConsuming, CancellationToken cancellationToken)

at Npgsql.NpgsqlCommand.ExecuteReader(Boolean async, CommandBehavior behavior, CancellationToken cancellationToken)

at Npgsql.NpgsqlCommand.ExecuteReader(Boolean async, CommandBehavior behavior, CancellationToken cancellationToken)

at Npgsql.NpgsqlCommand.ExecuteDbDataReaderAsync(CommandBehavior behavior, CancellationToken cancellationToken)

at Azure.DataApiBuilder.Core.Resolvers.QueryExecutor`1.ExecuteQueryAgainstDbAsync[TResult](TConnection conn, String sqltext, IDictionary`2 parameters, Func`3 dataReaderHandler, HttpContext httpContext, String dataSourceName, List`1 args) in /_/src/Core/Resolvers/QueryExecutor.cs:line 296

Exception data:

Severity: ERROR

SqlState: 42804

MessageText: column "u_response" is of type json but expression is of type text

Hint: You will need to rewrite or cast the expression.

Position: 62

File: parse_target.c

Line: 585

Routine: transformAssignedExpr

--- End of inner exception stack trace ---
```

### Code of Conduct

- [x] I agree to follow this project's Code of Conduct

Guida per i contributori

Apri la guida per i contributori

Direzione di ricerca

Inizia dalla gestione delle richieste REST e da QueryExecutor.cs intorno alla riga 296, usando il caso POST segnalato con una colonna JSON PostgreSQL per riprodurre il problema. Traccia il percorso del valore della richiesta fino al database; il lavoro è completo quando è possibile inserire un valore JSON tramite REST senza l’errore json-versus-text.

Scritto dal modello di indicizzazione a partire dal testo della issue.

Valutazione

Stack tecnologico
csharp, postgresql
Ambito
api, backend, database
Tipo di issue
Bug
Difficoltà
4/5
Tempo stimato
3-5 giorni
Stato di attività
Ferma
Chiarezza
Da chiarire
Idoneità per principianti
35/100

Ricevi le nuove issue nella tua casella

Un breve riepilogo di issue GitHub adatte ai principianti.