Inconsistent types in multiwatcher return values
Bug #1938205 reported by
Jeff Pihach
This bug affects 1 person
Affects | Status | Importance | Assigned to | Milestone | |
---|---|---|---|---|---|
Canonical Juju |
Triaged
|
Low
|
Unassigned |
Bug Description
The `id` in relation info is an `int`
https:/
But it's a number as a `string` everywhere else.
https:/
To post a comment you must log in.
Relation IDs are ints in the data model. They start at 1 and go up from there. Relations also have a "key" which is a string, and it's this value which we map onto the generic entity ID value
https:/ /github. com/juju/ juju/blob/ develop/ apiserver/ params/ multiwatcher. go#L353
Action IDs started out as strings - UUIDs in fact. We recently transitioned to using a numeric sequence as for relations but for compatibility need to retain the type as a string as there could still be older actions with UUIDs in the model.
So the multiwatcher types in the params structs for relations and actions are correct according to the requirements of the types used for the respective IDs. We will probably transition to using ints for action IDs in Juju 3 where we can break compatibility.
Note though that as a general rule, there's no requirement that different entities should model their IDs using the same type. Having said that, I wish we had bettered modelled the difference between database key (which should be opaque and consistent, either string or int), and natural key (machine name, application name etc). Sadly natural key and database key are often one and the same.