Project

General

Profile

Actions

Bug #9742

closed

API allows to create duplicate UUIDs at group creation

Added by Janos Mattyasovszky over 7 years ago. Updated about 7 years ago.

Status:
Released
Priority:
1
Category:
API
Target version:
Severity:
UX impact:
User visibility:
Effort required:
Priority:
Name check:
Fix check:
Regression:

Description

I can create a group with different names but the same UUID in different GroupCategories.

How to recreate:

API CALL #1:

# curl -s -X GET -H "X-API-Token: $APIKEY" -X PUT https://${URL}/rudder/api/latest/groups  \
> -d 'displayName=api test new group name 2' \
> -d 'description=description of the new group 2' \
> -d 'query={ "select": "node", "composition": "Or", "where": [{ "objectType": "node", "attribute": "OS", "comparator": "eq", "value": "Linux" }] }' \
> -d '8ecda055-094e-4b04-85ed-5c6235268ec7'
{
  "action": "createGroup",
  "id": "8ecda055-094e-4b04-85ed-5c6235268ec7",
  "result": "success",
  "data": {
    "groups": [
      {
        "id": "8ecda055-094e-4b04-85ed-5c6235268ec7",
        "displayName": "api test new group name 2",
        "description": "description of the new group 2",
        "query": {
          "select": "node",
          "composition": "Or",
          "where": [
            {
              "objectType": "node",
              "attribute": "OS",
              "comparator": "eq",
              "value": "Linux" 
            }
          ]
        },
        "nodeIds": [],
        "dynamic": true,
        "enabled": true,
        "isEnabled": true,
        "isDynamic": true
      }
    ]
  }
}

API CALL #2:

# curl -s -X GET -H "X-API-Token: $APIKEY" -X PUT https://${URL}/rudder/api/latest/groups \
> -d "category=5f2e3903-d3fe-40a4-8561-86017138e8ae" \
> -d 'displayName=api test new group name' \
> -d 'description=description of the new group' \
> -d 'query={ "select" : "node", "composition": "Or", "where": [] }' \
> -d 'id=8ecda055-094e-4b04-85ed-5c6235268ec7'  | jq
{
  "action": "createGroup",
  "id": "8ecda055-094e-4b04-85ed-5c6235268ec7",
  "result": "success",
  "data": {
    "groups": [
      {
        "id": "8ecda055-094e-4b04-85ed-5c6235268ec7",
        "displayName": "api test new group name",
        "description": "description of the new group",
        "query": {
          "select": "node",
          "composition": "Or",
          "where": []
        },
        "nodeIds": [],
        "dynamic": true,
        "enabled": true,
        "isEnabled": true,
        "isDynamic": true
      }
    ]
  }
}

This creates a group with the same UUID, which breaks stuff in the GUI. :-/

Apparently the API only checks the uniqueness of the Group Name, I only fail to create a differenlty named but same UUID Group in a GroupCategory:

# curl -s -X GET -H "X-API-Token: $APIKEY" -X PUT https://${URL}/rudder/api/latest/groups \
> -d "category=5f2e3903-d3fe-40a4-8561-86017138e8ae" \
> -d 'displayName=api test new group name 5' \
> -d 'description=description of the new group' \
> -d 'query={ "select" : "node", "composition": "Or", "where": [] }' \
> -d 'id=8ecda055-094e-4b04-85ed-5c6235268ec7'  | jq
{
  "action": "createGroup",
  "id": "8ecda055-094e-4b04-85ed-5c6235268ec7",
  "result": "error",
  "errorDetails": "Could not create Group api test new group name 5 (id:8ecda055-094e-4b04-85ed-5c6235268ec7) cause is: Bad change record type for requested action 'add node group': LDIFModifyChangeRecord(dn='nodeGroupId=8ecda055-094e-4b04-85ed-5c6235268ec7,groupCategoryId=5f2e3903-d3fe-40a4-8561-86017138e8ae,groupCategoryId=GroupRoot,ou=Rudder,cn=rudder-configuration', mods={LDAPModification(type=replace, attr=cn, values={'api test new group name 5'})})." 
}

It "only" fails because ldap has a contraint on the uniqueness of the UUID, so this is the last part the creation fails, but if I create it in a different GroupCategory.

Actions

Also available in: Atom PDF