[API] [BUG] Edit String/String Batch Operation - Identifier not unique if duplicated with an extra space

The API Endpoints Edit String and String Batch Operation return a notUnique code for identifier if 2 strings have the same identifier with an extra space for one of them.

When an identifier has an extra space at the end of the identifier, updating it either from the Edit Menu will do nothing. However when the string is edited using the Edit String or Batch Operation with the API, the operation will not be performed with the following error:

{
    "errors": [{
        "error": {
            "key": "identifier",
            "errors": [{
                "code": "notUnique",
                "message": "Invalid identifier given. Identifier must be unique"
            }]
        }
    }]
}

Step to reproduce:

  1. Get a brand new account (easier to view the issue without extra string not needed).
  2. Create a new empty project.
  3. Upload the following JSON File
{
  "Test String": "Test String",
  "Test String ": "Test String "
}
  1. Optionally: You can confirm that both strings got stored correctly with correct identifier with the List String or Get String Operations:
{
  "data": [
    {
      "data": {
        "id": 2,
        "identifier": "Test String",
        "text": "Test String"
      }
    },
    {
      "data": {
        "id": 4,
        "identifier": "Test String ",
        "text": "Test String "
      }
    }
  ]
}
  1. Send an Edit String Operation or a Batch String Operation to the project. Edit can be to replace context or text, for both of strings:
    Eg: Payload send of Edit String at https://crowdin.com/api/v2/projects/{projectId}/strings/2:
[{"op": "replace", "path":"/context", "value": "Test String Context Updated"}]

Actual Result:

{
    "errors": [{
        "error": {
            "key": "identifier",
            "errors": [{
                "code": "notUnique",
                "message": "Invalid identifier given. Identifier must be unique"
            }]
        }
    }]
}

Expected: Success of the operation as both strings have different identifiers (due to the space at the end for one of them).

Hello @Picsou993

Thanks for the detailed report and your contribution, much appreciated!

We will investigate this internally (45280)

1 Like