Skip to content

Malformed definition field in runtime parameters when exporting definitions #14793

@LoisSotoLopez

Description

@LoisSotoLopez

Describe the bug

When exporting definitions (rabbitmqctl export_definitions ./definitions.json) when e.g. an operator policy has been defined, the resulting parameters.value.definition field is malformed. This, as seen below, results on definition import failures.

Reproduction steps

  1. sbin/rabbitmqctl set_operator_policy transient-queue-ttl-1 "^amq\." '{"expires":1800000}' --priority 1 --apply-to queues
  2. sbin/rabbitmqctl export_definitions ./definitions.json
  3. sbin/rabbitmqctl import_definitions ./definitions.json
❯ sbin/rabbitmqctl set_operator_policy transient-queue-ttl-1 "^amq\." '{"expires":1800000}' --priority 1 --apply-to queues
Setting operator policy override "transient-queue-ttl-1" for pattern "^amq\." to "{"expires":1800000}" with priority "1" for vhost "/" ...

❯ sbin/rabbitmqctl export_definitions ./definitions.json
Exporting definitions in JSON to a file at "./definitions.json" ...

❯ sbin/rabbitmqctl import_definitions ./definitions.json
Importing definitions in JSON from a file at "./definitions.json" ...
Error:
Validation failed

definition must be a dictionary: [[<<"expires">>,1800000]]
 (vhost: "/" / component: "operator_policy" / key: "transient-queue-ttl-1")

Expected behavior

Importing definition should succeed.

Additional context

There's a comment on export_definitions_command.ex at serialise/2 before the JSON.encode/1 of the definitions saying rabbit_definitions already takes care of transforming all proplists into maps, but I don't think it does.

My immediate solution was to change this line but based on the mentioned comment maybe the change should be in rabbit_definitions around here.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions