Hello, It is possible to find source of `Request f...
# community-help
s
Hello, It is possible to find source of `Request failed with HTTP code 400 | Server said: Field
**
has an incorrect type.` error when updating schema on already existing collection? I have tried to export data and check for any corrupted fields but wasn't able to find anything wrong
k
Might be some edge case because field name
**
sounds weird. Are you able to share the data directory with me via DM so I can take a look? You can just zip it and share if it's something you are comfortable sharing.
s
I'm running on cloud typesense and field name is not
**
I just recorded it for purpose of sending this message original error is `Error: e: Request failed with HTTP code 400 | Server said: Field
properties.WORK.assignee.value
has an incorrect type.`
where
properties.WORK.assignee.value
can be
null | [] | string[]
Copy code
{
  "fields": [
    {
      "facet": true,
      "index": true,
      "infix": false,
      "locale": "",
      "name": "properties.WORK.assignee.value",
      "optional": true,
      "sort": false,
      "type": "auto"
    }
  ]
}
This is schema update I'm trying to apply
k
There was an issue that I fixed a couple of weeks back that involved a nested value being null. This might be related to it. Are any of the existing records null on-disk (for this field)?
s
Yes there are some
Cluster has
Typesense v0.24.0
version might be related ?
k
Hold on let check if that could be an issue.
*that == null values
👍 1
🙌 1
Hmm I am not able to reproduce that on a simple collection. Mind if I take a look at your collection? Can you DM me the cluster ID and collection name.
👍 1
Ah, I just realized that the type cannot be
auto
--> it must be a concrete type.
While the type can be auto during schema declaration, for schema changes, it needs to be a concrete type.
Try using
string[]
--> it should work!
s
Thank you, works perfectly :))
🙌 1
I have this problem again on same cluster 😞
message has been deleted
message has been deleted
k
Do you already have records with that value but with a different type?
s
It worked perfectly until yesterday but something has happened and our schema got "reseted" without any action from us. After that I cannot update schema back to support this field. I believe that if this field configuration was present every insert of document with invalid data would get rejected. Or is there different behaviour?
I can download data again a check the types there if needed
Didn't find any inconsistency in our data
k
Ok let me check. Give me an hour or so.
👍 1
Can you please post the update schema you tried (in the screenshot) as text here?
s
sure
Copy code
{
  "fields": [
    {
      "facet": true,
      "index": true,
      "infix": false,
      "locale": "",
      "name": "properties.WORK.assignee.value",
      "optional": true,
      "sort": false,
      "type": "string[]"
    }
  ]
}
k
Thanks, debugging now. Will keep you posted shortly.
👍 1
properties.WORK.assignee.value
seems to be an array of objects?
s
No it's always array of string
Copy code
[{
  "lastUpdateBy": "KOBQAiHm8eTYmdYDSJtHfnxOBIv1",
  "updatedAt": {
    "_nanoseconds": 583000000,
    "_seconds": 1676508480
  },
  "value": [
    "KOBQAiHm8eTYmdYDSJtHfnxOBIv1"
  ]
}
,{
  "lastUpdateBy": "AJSUE9y9RtZw5BY7AIqafyPHhgT2",
  "updatedAt": {
    "_nanoseconds": 415000000,
    "_seconds": 1675938146
  },
  "value": [
    "AJSUE9y9RtZw5BY7AIqafyPHhgT2"
  ]
}]
k
See here I found one with an array of objects:
Copy code
"properties":{
      "WORK":{
         "assignee":{
            "lastUpdateBy":"CWzdjyOShMg4bHeGO4NkJzigLnE2",
            "updatedAt":{
               "_nanoseconds":660000000,
               "_seconds":1678966234
            },
            "value":[
               {
                  "displayName":"Social media manager",
                  "id":"Social media manager"
               }
            ]
         },
s
oh wow
I'm sorry, I did all I was able via
jq '.properties.WORK.assignee | select(.properties...'
but didn't found that object
k
Sorry for the trouble here -- we really should be surfacing the
id
of the bad document along with the error message
Check doc id
NR4FCzUQgqjQGtP6Tzzy
The other thing I just realized we are unable to support right now is to add a new
object[]
field. This is a limitation that we have to address.
s
Thank you for your help! I found the docs with invalid data and sorry I took your time
just one question, If I will fix those bad data, and I will update the schema, then I will try to insert document with incos. data will it get rejected ?
k
No worry. I truly consider every question an area for us to improve on.
s
for example I will have set a correct schema type now to
string[]
and I will do the document.insert() which will contain invalid data. Will it get rejected ?
k
I don't get your question. If you fix that document and retry the schema update you have to target primitive types like string [] yes
Once you have a schema change done, subsequent docs inserted have to conform
👍 1