Error on basket snapshot restore: Basket does not support '0' (BasketSnapshot.php:117)

Hi community! :slightly_smiling_face:

I’m trying to restore a Director basket snapshot, taken on one system (my production server), into another system (my test server).

All else being equal on both systems (same versions and config of icinga2, icingadb, icingaweb2 and director [except for obvious differences like PKI]), the restore fails with the error:

Basket does not support '0' (BasketSnapshot.php:117)

The json-File looks good, there’s no “type” = “0” to be found; no error in the Director-Database either.

Do you have any hint where I could look to further diagnose the problem?

(I. e. maybe Director has a log file (apart from the activity log) I’m not aware of yet…?)

Thanks!

  • Barney
  • Director version (System - About): 1.10.2
  • Icinga Web 2 version and modules (System - About): 2.11.4
  • Icinga 2 version (icinga2 --version): r2.13.7-1
  • Operating System and version: Debian 11
  • Webserver, PHP versions: Apache 2.46 & PHP 7.4.33

Well… as it turns out, not doing one huge backup of all director objects in one basket can help with further diagnosis. :crazy_face:

I’ve done an export by object category (datalists, dependencies, hosts, hostgroups etc.) and found the culprit to be in the “basket definitions” (which can also be included in snapshots and therefore backups and restores).

I’ll investigate further; let’s see where this leads…

1 Like

Hi

I got the same problem when I tried to import a just exported Basket snapshot containing a Basket definition.
I managed to do that earlier this year and had a working copy in git.
The difference was in the Basket definition in the snapshot. The working version has the objects in the Basket as proper JSON structure:

    "Basket": {
        "my-servers": {
            "basket_name": "my-servers",
            "objects": {
                "HostGroup": [
                    "my-servers"
                ],
                "ImportSource": [
                    "my-servers-import"
                ],
                "SyncRule": [
                    "my-servers-sync-rule"
                ],
                "Basket": [
                    "my-servers"
                ]
            },
            "owner_type": "usergroup",
            "owner_value": "my-group"
        }
    }

whereas the broken one has the objects listed as stringified JSON:

    "Basket": {
        "my-servers": {
            "basket_name": "my-servers",
            "objects": "{\"HostGroup\":[\"my-servers\",\"my-servers\",\"my-servers\"],\"ImportSource\":[\"my-servers-import\",\"my-servers-import\",\my-servers-import\"],\"SyncRule\":[\"my-servers-sync-rule\",\"my-servers-sync-rule\",\"my-servers-sync-rule\"],\"Basket\":[\"my-servers\",\"my-servers\",\my-servers\"]}",
            "owner_type": "usergroup",
            "owner_value": "my-group"
        }
    }

(and three copies, for whatever reason).

After changing the snapshot file to provide the objects as proper JSON the import worked again.
Looks like a new bug to me.

I opened a bug: broken Basket definitions in Basket snapshots · Issue #2774 · Icinga/icingaweb2-module-director · GitHub

1 Like