You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I played around with the netbox.get.dcim.devices action. When I execute it without any parameters, it returns all the devices, which is expected. There is also the 'id' parameter. I assumed that I can get the data from a specific device with it. I realized that I need to enter a list. So I executed the action with an 'id' of '[1]'.
The return value of the action is this:
{
"raw": {},
"status": 404
}
In the nginx access logs from Netbox there is the following entry:
My understanding is that '%5B1%5D/' represents '[1]'. So the action tries to access '/api/dcim/device/[1]...'.
Am I using the id parameter in the wrong way?
if http_verb == 'get':
if kwargs.get('id', False) and get_detail_route_eligible:
# modify the `endpoint_uri` to use the detail route
endpoint_uri = '{}{}/'.format(endpoint_uri, str(kwargs.pop('id')))
self.logger.debug(
'endpoint_uri transformed to {} because id was passed'.format(endpoint_uri)
)
For this to work it must be only one ID used in the get, and the [] must be stripped. And it may be hitting all the get actions when ID is used.
Do you mean something like tihs: endpoint_uri = '{}{}/'.format(endpoint_uri, str(kwargs.pop('id')[0]))
No, I just pointed out the api request is changed when ID is used. If other fields is used it works with more than one. When the api is the way it is it support just one.
I don't use the ID in my workflows, so I have not been hit by this.
We’re seeing this too on v3.4.4 after upgrading from 3.0.5. In 3.0.5 the id parameter for get.dcim.devices was a string, so st2 run netbox.get.dcim.devices id=105587 correctly hit /api/dcim/devices/105587/. In 3.4.4 the action schema now declares id as type: array, so StackStorm passes id as a list (e.g. [105587] or [105587, 1234]).
Because actions/run.py still does endpoint_uri = "{}{}/".format(endpoint_uri, str(kwargs.pop("id"))), the detail-route URL becomes /dcim/devices/[105587]/ for a single id, or /dcim/devices/[105587, 1234]/ for an array of ids, which NetBox rightly 404s.
I have a fixed version which I will raise a PR for shortly.
Activity
aopdal commentedon Feb 26, 2024
I think you are right, when I test creating a workflow using the action like this:
I get:
st2.actions.python.NetboxHTTPAction: DEBUG endpoint_uri transformed to /dcim/devices/[1]/ because id was passedWhen I try in NetBox API /api/dcim/devices/{id}/ I get:
/api/dcim/devices/1/And If I tries
I get
endpoint_uri transformed to /dcim/devices/[1, 2]/ because id was passedBut I want something like:
api/dcim/devices/?id=1&id=2So I think it looks like the action get.dcim.devices is a combination of two API endpoints:
/api/dcim/devices/
/api/dcim/devices/{id}/
aopdal commentedon Feb 26, 2024
Looks like its her in the run.py:
For this to work it must be only one ID used in the get, and the [] must be stripped. And it may be hitting all the get actions when ID is used.
rgrueebler commentedon Feb 28, 2024
Do you mean something like tihs:
endpoint_uri = '{}{}/'.format(endpoint_uri, str(kwargs.pop('id')[0]))
aopdal commentedon Feb 28, 2024
No, I just pointed out the api request is changed when ID is used. If other fields is used it works with more than one. When the api is the way it is it support just one.
I don't use the ID in my workflows, so I have not been hit by this.
johanek commentedon Mar 3, 2026
We’re seeing this too on v3.4.4 after upgrading from 3.0.5. In 3.0.5 the id parameter for get.dcim.devices was a string, so st2 run netbox.get.dcim.devices id=105587 correctly hit /api/dcim/devices/105587/. In 3.4.4 the action schema now declares id as type: array, so StackStorm passes id as a list (e.g. [105587] or [105587, 1234]).
Because actions/run.py still does
endpoint_uri = "{}{}/".format(endpoint_uri, str(kwargs.pop("id"))), the detail-route URL becomes/dcim/devices/[105587]/for a single id, or/dcim/devices/[105587, 1234]/for an array of ids, which NetBox rightly 404s.I have a fixed version which I will raise a PR for shortly.