Skip to content

Auth Snaplet users.json format change #214

@imalsogreg

Description

@imalsogreg

At some point in the last several years, the format for users.json changed, specifically the uidCache field. The one in use by a deployment of https://github.com/imalsogreg/reffit several years old was encoded as:

{ uidCache:
  [
    [ 999,
      {
        "last_ip": null,
        "roles": [],
        "current_ip": "127.0.0.1",
        "activated_at": null,
        "reset_requested_at": null,
        "uid": "999",
         ...
        "login": "Interfacelea",
        "reset_token": null
      }
    ],
    ...
  ],
  ...
}

(id and info tuples were in a list of length-2 lists, not key-value entries in a map)

When I bumped snap to the most recent version, parsing failed because the new format is expected to be key-value pairs in a map:

{ uidCache:
  { "999":
    {
      "last_ip": null,
      "roles": [],
      "current_ip": "127.0.0.1",
      "activated_at": null,
      "reset_requested_at": null,
      "uid": "999",
       ...
      "login": "Interfacelea",
      "reset_token": null
    }
    ...
  },
  ...
}

Apologies for vagueness about the dates - I'd need to do some research to get more details.

If anyone else runs into this, the following jq call can do the migration:

jq '.uidCache = ([.uidCache[] | { "key": .[0], "value": .[1] }] | from_entries)' users.json

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