uselagoon / lagoon

Lagoon, the developer-focused application delivery platform
https://docs.lagoon.sh/
Apache License 2.0
552 stars 149 forks source link

API uses `Int` for backup restore sizes which can be larger than `Int` size #3629

Closed rocketeerbkw closed 6 months ago

rocketeerbkw commented 7 months ago

Describe the bug

The GraphQL type for the restoreSize field is set as Int which only allows signed 32-bit integers. Since the size is recorded in bytes, this can be larger than the Int type. In this case the api will error with: Int cannot represent non 32-bit signed integer value

To Reproduce

Steps to reproduce the behavior:

  1. Restore a backup larger than 2.2GB
  2. Attempt to retrieve restore info from the api (or view the backups page in the UI)

Expected behavior

The api stores and retrieves restore size without errors.

Additional context

Introduced in https://github.com/uselagoon/lagoon/pull/3599.

shreddedbacon commented 7 months ago

Is Float the better one to use, since we use it for storage bytes? https://github.com/uselagoon/lagoon/blob/main/services/api/src/typeDefs.js#L947

rocketeerbkw commented 7 months ago

Is Float the better one to use, since we use it for storage bytes? https://github.com/uselagoon/lagoon/blob/main/services/api/src/typeDefs.js#L947

I checked the graphql spec and it doesn't specify what the max size of a float is. There's a random comment on a SO question that says it's 52 or 128 bits.... but no source was provided.

I would expect the storage calculator and restore sizes to be mostly equivalent, so if it works for storage I suppose it should be fine for restores.