•  
      request #35818 XML Import breaks the expert query on empty string
    Infos
    #35818
    Guilhem Bonnefille (CS) (gbonnefille)
    2024-02-09 13:11
    2024-01-04 18:19
    37411
    Details
    XML Import breaks the expert query on empty string

    Steps to reproduce

    • Create a tracker from the Bugs template.
    • Create 2 items, 1 without adding details, 1 with details
    • Requesting details = '' only select the 1 item.

    Then :

    • export the tracker
    • in the project.xml, remove all reference to field_change on detail where data is empty
    • change the tracker's name+id
    • import the tracker

    Finally, in this new tracker, the request details = '' does not return anything.

    Additional information

    In my investigations, I noticed the expert query is made against the ChangeSets. And, effectively, in such situation, the ChangeSet does not have the field details=''.

    In real world, the XML import file was generated by an internal migration tool. And in this tool, we did not generate field_change for string with empty value. Based on the code, this is explicit, but I don't remember WHY (bad commit message).

    Import | Export
    15.2
    Empty
    • [ ] enhancement
    • [ ] internal improvement
    Empty
    Stage
    Empty
    New
    Empty
    Attachments
    Empty
    References
    References list is empty

    Follow-ups

    User avatar

    I think I found a solution, with tuleap-cli and jq:

    tuleap-cli -s tuleap.example.com -u admin -P trackers --id 42 artifacts --values all |   jq '{id,"value":((.values[]|select(.field_id == 1550))//"not-found")}|select (.value == "not-found")|.id'
    

    Now I have the id of the affected artifacts... I need to fix them.

    User avatar

    Thanks for the feedback. Yes, of course, it's not great to deal with the DB directly. But I didn't find any other solution.

    One solution would be to use the Mass Update to reset these fields. I have to find a way to select these artifacts.

    User avatar

    Your solution looks like OK.

    However we don't like much when users manipulate directly the database, do it at your own risk.

    User avatar

    @vaceletm in order to mitigate the situation, I imagine to correct the database directly. But I'm not really confident with such change, so I request your review.

    I understood the matter is the lack of empty value for the related field (type=string). So I plan to add this value to the last_changeset. In order to do this, I imagine to:

    • add a new entry in tracker_changeset_value
    • add a new entry in tracker_changeset_value_text directly via SQL command.

    Is it OK? Do I miss something?