Skip to content

[BUG] creating an existing principal role assignment returns 500 instead of 409 #226

Closed
@TomerHeber

Description

@TomerHeber

Is this a possible security vulnerability?

  • This is NOT a possible security vulnerability

Describe the bug

When I try to assign between a principal role and a principal I get 2xx.
If I try to run the same assignment again (conflict) I will get 5xx.

To Reproduce

  1. Create a principal.
  2. Create a principal role.
  3. Assign role to principal.
  4. Assign role to principal (again).

Actual Behavior

500 error.

{
    "error": {
        "message": "Exception [EclipseLink-4002] (Eclipse Persistence Services - 4.0.3.v202405220658): org.eclipse.persistence.exceptions.DatabaseException\nInternal Exception: org.postgresql.util.PSQLException: ERROR: duplicate key value violates unique constraint \"grant_records_pkey\"\n  Detail: Key (granteecatalogid, privilegecode, granteeid, securableid, securablecatalogid)=(0, 4, 1599, 1149, 0) already exists.\nError Code: 0\nCall: INSERT INTO GRANT_RECORDS (GRANTEECATALOGID, PRIVILEGECODE, GRANTEEID, SECURABLEID, SECURABLECATALOGID, VERSION) VALUES (?, ?, ?, ?, ?, ?)\n\tbind => [0, 4, 1599, 1149, 0, 1]\nQuery: InsertObjectQuery(org.apache.polaris.core.persistence.models.ModelGrantRecord@5780643b)",
        "type": "PersistenceException",
        "code": 500
    }
}

Expected Behavior

409 - conflict.

Additional context

No response

System information

N/A

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions