Skip to content

Unable to delete profile mappings #534

@nxy28

Description

@nxy28

Describe the bug?

Hello,

Some endpoints have a disclaimer in the API docs that says:

Note: You must set properties explicitly to null to remove them from the schema; otherwise, POST is interpreted as a partial update.

This is not explicitly called out in the Update a profile mapping endpoint, however it does say that mappings can be removed and via testing I have found that the above rule applies.

For that endpoint, the SDK wants this request:

type ProfileMappingRequest struct {
	Properties           map[string]ProfileMappingProperty `json:"properties"`
	AdditionalProperties map[string]interface{}
}

Because ProfileMappingProperty is a value and not a pointer, it is impossible to send null. Instead it sends an empty object that fails validation.

{
  "errorCode": "E0000002",
  "errorSummary": "The request was not valid: Invalid mapping input: Source expression for a property mapping cannot be null or empty string",
  "errorLink": "E0000002",
  "errorId": "oae1OKUqzhpRMqcZgQUSlGb6A",
  "errorCauses": []
}

What is expected to happen?

If the request required map[string]*ProfileMappingProperty, it would allow null in the request, allowing the mapping to be deleted.

What is the actual behavior?

The request fails validation.

Reproduction Steps?

Here is a Python example:

# this will delete the mapping
def this_works(mapping_id: str):
    url = f"{okta_host}/api/v1/mappings/{mapping_id}"
    payload = {
        "properties": {
            "state": None
        }
    }
    resp = requests.post(url=url, headers=get_headers(), json=payload)
    return resp

# this returns a validation error
def this_does_not_work(mapping_id: str):
    url = f"{okta_host}/api/v1/mappings/{mapping_id}"
    payload = {
        "properties": {
            "state": {
                "expression": None,
                "pushStatus": None
            }
        }
    }
    resp = requests.post(url=url, headers=get_headers(), json=payload)
    return resp

Additional Information?

n/a

Golang Version

go version go1.23.0 darwin/arm64

SDK Version

github.com/okta/okta-sdk-golang/v5 v5.0.6

OS version

Darwin ATL100000833063 23.6.0 Darwin Kernel Version 23.6.0: Mon Jul 29 21:14:30 PDT 2024; root:xnu-10063.141.2~1/RELEASE_ARM64_T6000 arm64

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't workingstale

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions