threefoldtech / tfchain_graphql

Graphql for TFchain
Apache License 2.0
2 stars 3 forks source link

Invalid Country/City values crashed the processor on devnet #143

Closed Mahmoud-Emad closed 9 months ago

Mahmoud-Emad commented 9 months ago

Description

While testing node creation via the Polkadot UI, I encountered an unexpected behavior. Specifically, when setting the values of Country and City as random numbers, it resulted in a processor crash.

Related Issue

This issue has been documented and can be tracked here.

Node details

{
  version: 5
  id: 143
  farmId: 4,413
  twinId: 1,214
  resources: {
    hru: 1,073,741,824,000
    sru: 1,610,612,736,000
    cru: 1
    mru: 1,073,741,824,000
  }
  location: {
    city: 0x4413000150
    country: 0x4413000150
    latitude: 31.8105
    longitude: 31.8105
  }
  publicConfig: null
  created: 1,702,558,662
  farmingPolicyId: 1
  interfaces: []
  certification: Diy
  secureBoot: false
  virtualized: false
  serialNumber: null
  connectionPrice: 80
}
MarioBassem commented 9 months ago

i added a check to detect invalid country/city values, still to be tested

coesensbert commented 9 months ago

i added a check to detect invalid country/city values, still to be tested

Where is this fix documented? So we can apply to other backends

MarioBassem commented 9 months ago

the issue with the processor was that the country/city string was a hexadecimal encoded invalid utf-8 value, which postgres couldn't store as text. the fix was to replace these invalid values with empty strings, a temporary solution until invalid values are validated against in the tfchain.

MarioBassem commented 9 months ago

the fix in #144 didn't work because the input started with a valid byte 'D' image

updated the fix to search for the invalid data in the entire Uint8Array, and tested it against devnet, the processor was able to process the bad country/city inputs and replaced them with empty strings