Skip to content

DROP FOLDER deletes JSON structures that LIST FOLDERS does not count - silent document loss #892

Description

@Chendodelangen

Summary

LIST FOLDERS does not count JSON structures as folder members, so a folder that holds them reports [0]. DROP FOLDER then deletes them along with the folder. The listing that a script would use to decide "this folder is empty, it can go" is the one that cannot see the documents it is about to destroy.

Environment

  • mxcli v0.17.0, windows/amd64
  • Studio Pro 11.12.2, MPR format v2

What happened

A module had a Studio Pro-created folder JSON structures containing 7 JSON structures, each bound to an import mapping.

mxcli -p app.mpr -c "LIST FOLDERS MyModule"
...
  JSON structures  [0]

Based on that count the folder was dropped:

DROP FOLDER MyModule.'JSON structures';

The folder and all 7 structures were gone, and every bound mapping went to CE1613 ("... no longer exists") on the next Studio Pro open. Recovery was only possible because the MDL sources that had created the structures still existed.

Verifiable without Studio Pro (v0.17.0)

The listing gap is not a display detail; mxcli has no folder-awareness for this document type at all:

CREATE JSON STRUCTURE MyModule.ZZ_Probe FOLDER 'ZZProbe' SNIPPET '{"id": 1}';
-- Parse error: line 1:71 mismatched input 'FROM' expecting {SNIPPET, COMMENT}
-- (no FOLDER clause exists on CREATE JSON STRUCTURE)

MOVE JSON STRUCTURE MyModule.ZZ_Probe TO 'ZZProbe';
-- Parse error: no viable alternative at input 'MOVEJSON'
-- (MOVE does not accept JSON STRUCTURE)

So a JSON structure can only be placed in a folder from Studio Pro, mxcli cannot see it there, and mxcli will still delete it with the folder.

Expected

Either of these would have prevented the loss:

  1. LIST FOLDERS counts and lists every document type a folder can contain (at minimum: whatever DROP FOLDER is capable of deleting).
  2. DROP FOLDER refuses, or requires an explicit CASCADE, when the folder contains documents of types the listing cannot enumerate.

Also worth considering: FOLDER / MOVE support for JSON structures and mappings, so the folder structure a team maintains in Studio Pro is reachable from scripts at all.

Impact

Silent, unrecoverable document loss from a command whose own diagnostics said the folder was empty. The failure only surfaces later as CE1613 on every mapping that used the structures.

Context: found while cleaning up after building a complete Odoo connector end to end with mxcli.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions