[API] [BUG] String Batch Operations - Strings recreated when extra space on String Identifier

The API Endpoint String Batch Operation (API v2 Reference) is inconsistency and recreate some strings without previous information such as translations, context etc… It also recreate them with a different String ID.

When a key has an extra space at the end of the key, updating it either from the Edit Menu or the Edit String endpoint will do nothing. However when the string is edited using the Batch Operation, the string will be deleted and recreated without any translation and with its key without extra space. This occurs even if you don’t edit the entire string but only replace the context.

Step to reproduce:

  1. Get a brand new account (so String Id will start at 1 and it’s gonna be easier to view the issue).
  2. Create a new empty project.
  3. Upload the following JSON File
{
  "Space Id One ": "Id 1 ",
  "No Space Id Three": "Id 3",
  "Space Id Five ": "Id 5 ",
  "No Space Id Seven": "Id 7",
  "Space Id Nine ": "Id 9 ",
  "No Space Id Eleven": "Id 11",
  "Space Id Thirteen ": "Id 13 "
}
  1. Optionnally: Translate them.
  2. Send the following Batch Operation to the project:
[{"op":"replace","path":"/1/context","value":"Context for String Id 1"},
{"op":"replace","path":"/3/context","value":"Context for String Id 3"},
{"op":"replace","path":"/5/context","value":"Context for String Id 5"},
{"op":"replace","path":"/7/context","value":"Context for String Id 7"},
{"op":"replace","path":"/9/context","value":"Context for String Id 9"},
{"op":"replace","path":"/11/context","value":"Context for String Id 11"},
{"op":"replace","path":"/13/context","value":"Context for String Id 13"}]
  1. Observe that the result returns new String Id and that the Strings Ids 1, 5 and 9 have changed.
  2. Observe that the String Id 13 has not changed for some reasons (String identifier has changed to remove the space).
  3. Observe that the context has not changed at all except for String Id 13.
    Simplified JSON Result after the Batch Operation:
{
    "data": [{
        "data": {
            "id": 15,
            "identifier": "Space Id One",
            "text": "Id 1 ",
            "context": " -> Space Id One"
        }
    }, {
        "data": {
            "id": 3,
            "identifier": "No Space Id Three",
            "text": "Id 3",
            "context": " -> No Space Id Three"
        }
    }, {
        "data": {
            "id": 17,
            "identifier": "Space Id Five",
            "text": "Id 5 ",
            "context": " -> Space Id Five"
        }
    }, {
        "data": {
            "id": 7,
            "identifier": "No Space Id Seven",
            "text": "Id 7",
            "context": " -> No Space Id Seven"
        }
    }, {
        "data": {
            "id": 19,
            "identifier": "Space Id Nine",
            "text": "Id 9 ",
            "context": " -> Space Id Nine"
        }
    }, {
        "data": {
            "id": 11,
            "identifier": "No Space Id Eleven",
            "text": "Id 11",
            "context": " -> No Space Id Eleven"
        }
    }, {
        "data": {
            "id": 13,
            "identifier": "Space Id Thirteen",
            "text": "Id 13 ",
            "context": "Context for String Id 13"
        }
    }]
}
  1. Rerunning the Batch Operation with the new ID will now work correctly without issue.
    New code for the Batch Operation with the new ID:
[{"op":"replace","path":"/15/context","value":"Context for String Id 1"},
{"op":"replace","path":"/3/context","value":"Context for String Id 3"},
{"op":"replace","path":"/17/context","value":"Context for String Id 5"},
{"op":"replace","path":"/7/context","value":"Context for String Id 7"},
{"op":"replace","path":"/19/context","value":"Context for String Id 9"},
{"op":"replace","path":"/11/context","value":"Context for String Id 11"},
{"op":"replace","path":"/13/context","value":"Context for String Id 13"}]

New simplified result from the Batch Operation:

{
    "data": [{
        "data": {
            "id": 15,
            "identifier": "Space Id One",
            "text": "Id 1 ",
            "context": "Context for String Id 1"
        }
    }, {
        "data": {
            "id": 3,
            "identifier": "No Space Id Three",
            "text": "Id 3",
            "context": "Context for String Id 3"
        }
    }, {
        "data": {
            "id": 17,
            "identifier": "Space Id Five",
            "text": "Id 5 ",
            "context": "Context for String Id 5"
        }
    }, {
        "data": {
            "id": 7,
            "identifier": "No Space Id Seven",
            "text": "Id 7",
            "context": "Context for String Id 7"
        }
    }, {
        "data": {
            "id": 19,
            "identifier": "Space Id Nine",
            "text": "Id 9 ",
            "context": "Context for String Id 9"
        }
    }, {
        "data": {
            "id": 11,
            "identifier": "No Space Id Eleven",
            "text": "Id 11",
            "context": "Context for String Id 11"
        }
    }, {
        "data": {
            "id": 13,
            "identifier": "Space Id Thirteen",
            "text": "Id 13 ",
            "context": "Context for String Id 13"
        }
    }]
}

As we can see now the context has been successfully added and the string didn’t got recreated as the identifier doesn’t have an extra space anymore.

Hi Picsou993,

Thank you for such a detailed description! :blush:

I will check it with a team and get back to you,

1 Like

Hi Picsou993,

Our team confirmed that it is an unexpected behaviour from our side. Created a task on the matter for our devs,

Thank you a lot for your contribution! :rocket:

1 Like

Hi Picsou993.

Hope you are doing great :))

Just want to let you know that our developers fixed the issue with String Batch Operations.

1 Like