Azure / Azure/data-api-builder
[Bug]: JSON data in POST request is handled as text
- Vorherrschende Sprache
- C#
- Sterne
- 1.5k
- Forks
- 370
- Ø Merge
- 3 T. 22 Std.
- Gemergte PRs (30 T.)
- 9
Beschreibung
### 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.
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
Beitragsleitfaden
Rechercherichtung
Beginne mit der REST-Anforderungsverarbeitung und QueryExecutor.cs um Zeile 296 und verwende den gemeldeten POST-Fall mit einer PostgreSQL-JSON-Spalte, um den Fehler zu reproduzieren. Verfolge, wie der Anforderungswert die Datenbank erreicht; fertig ist die Aufgabe, wenn ein JSON-Wert über REST ohne den Fehler json-versus-text eingefügt werden kann.
Vom Indexierungsmodell aus dem Issue-Text verfasst.
Bewertung
- Tech-Stack
- csharp, postgresql
- Bereich
- api, backend, database
- Issue-Typ
- Bug
- Schwierigkeit
- 4/5
- Geschätzter Aufwand
- 3-5 Tage
- Aktivitätsstatus
- Veraltet
- Klarheit
- Muss geklärt werden
- Anfängerfreundlichkeit
- 35/100