Skip to content

"Could not convert to String: <null>" error with empty strings #143

Closed
@juanLovera

Description

@juanLovera

Describe the bug

After upgrading to postgres-nio 1.5.0, our server started crashing with a bunch of errors like this:

[ ERROR ] invalid field: stripe_id type: String error: typeMismatch(Swift.String, Swift.DecodingError.Context(codingPath: [], debugDescription: "Could not convert to String: <null>", underlyingError: nil)) [request-id: 4A11F25B-AD9C-43EC-BC9B-996A434DBAF2]

The indicated field is non-null on Postgres and non optional on Swift. I discovered that this is happening when the field's value is an empty string, so it would seem like empty strings are being treated as null values.

To Reproduce

  1. Create non-null text field in postgres.
  2. Create Vapor model and connect with that field (with a non optional var)
  3. Add a new row with an empty string.
  4. Try to fetch that row in Vapor -> it should crash.

Expected behavior

It should return the empty string instead of crashing.

Vapor 4.32.0
Fluent 4.0.0
Postgres-nio 1.5.0
Postrges 11.5

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions