Primary key values in the ontology seem to enforce UUID

Does the ontology allow non uuid values as primary keys? I have an existing object that contains uuid values for all object’s primary key values. When I attempt to create a new object using a non uuid value that is still unique I get a 400 bad request invalid argument error. For example consider this cURL request:

curl -X POST "https://<MY_STACK>.palantirfoundry.com/api/v2/ontologies/<MY_ONTOLOGY_ID>/actions/upsert-machine/apply" \
    -H "Authorization: Bearer $TOKEN" \
    -H "Content-Type: application/json" \
    --data-raw '{
        "parameters": {
            "id": "2db9613b-39e4-4093-b8e5-d8a2ca355568", 
            "stateMachine": "[{\"id\":\"sendEmail|61571660-9328-4c67-8bdd-fb39a6ed55bf\",\"transitions\":[{\"on\":\"CONTINUE\",\"target\":\"sendSlackMessage|4c339eb2-877e-4f67-ac16-2146ea37df83\"},{\"on\":\"ERROR\",\"target\":\"failure\"}]},{\"id\":\"sendSlackMessage|4c339eb2-877e-4f67-ac16-2146ea37df83\",\"transitions\":[{\"on\":\"CONTINUE\",\"target\":\"success\"},{\"on\":\"ERROR\",\"target\":\"failure\"}]},{\"id\":\"success\",\"type\":\"final\"},{\"id\":\"failure\",\"type\":\"final\"}]", 
            "state": "{\"actions\":[{\"type\":\"entry\"}],\"activities\":{},\"meta\":{},\"events\":[],\"value\":\"sendEmail|61571660-9328-4c67-8bdd-fb39a6ed55bf\",\"context\":{\"status\":0,\"requestId\":\"test\",\"stack\":[\"sendEmail|61571660-9328-4c67-8bdd-fb39a6ed55bf\"]},\"_event\":{\"name\":\"xstate.init\",\"data\":{\"type\":\"xstate.init\"},\"$$type\":\"scxml\",\"type\":\"external\"},\"_sessionid\":\"x:1\",\"event\":{\"type\":\"xstate.init\"},\"children\":{},\"done\":false,\"tags\":[]}", 
            "logs": "value"
        },
        "options": {
            "returnEdits": "ALL"
        }
    }'

This request succeeds and returns:

{"validation":{"result":"VALID","submissionCriteria":[],"parameters":{}},"edits":{"type":"edits","edits":[{"type":"addObject","primaryKey":"2db9613b-39e4-4093-b8e5-d8a2ca355590","objectType":"MachineExecutions"}],"addedObjectCount":1,"modifiedObjectsCount":0,"deletedObjectsCount":0,"addedLinksCount":0,"deletedLinksCount":0}}

But if I just change the ID to “0822c4d4399066b61e484e841791aa8be7f03454ae06f573abce25c825a115a8” if it fails:

curl -X POST "https://<MY_STACK>.palantirfoundry.com/api/v2/ontologies/<MY_ONTOLOGY_ID>/actions/upsert-machine/apply" \
    -H "Authorization: Bearer $TOKEN" \
    -H "Content-Type: application/json" \
    --data-raw '{
        "parameters": {
            "id": "0822c4d4399066b61e484e841791aa8be7f03454ae06f573abce25c825a115a8", 
            "stateMachine": "[{\"id\":\"sendEmail|61571660-9328-4c67-8bdd-fb39a6ed55bf\",\"transitions\":[{\"on\":\"CONTINUE\",\"target\":\"sendSlackMessage|4c339eb2-877e-4f67-ac16-2146ea37df83\"},{\"on\":\"ERROR\",\"target\":\"failure\"}]},{\"id\":\"sendSlackMessage|4c339eb2-877e-4f67-ac16-2146ea37df83\",\"transitions\":[{\"on\":\"CONTINUE\",\"target\":\"success\"},{\"on\":\"ERROR\",\"target\":\"failure\"}]},{\"id\":\"success\",\"type\":\"final\"},{\"id\":\"failure\",\"type\":\"final\"}]", 
            "state": "{\"actions\":[{\"type\":\"entry\"}],\"activities\":{},\"meta\":{},\"events\":[],\"value\":\"sendEmail|61571660-9328-4c67-8bdd-fb39a6ed55bf\",\"context\":{\"status\":0,\"requestId\":\"test\",\"stack\":[\"sendEmail|61571660-9328-4c67-8bdd-fb39a6ed55bf\"]},\"_event\":{\"name\":\"xstate.init\",\"data\":{\"type\":\"xstate.init\"},\"$$type\":\"scxml\",\"type\":\"external\"},\"_sessionid\":\"x:1\",\"event\":{\"type\":\"xstate.init\"},\"children\":{},\"done\":false,\"tags\":[]}", 
            "logs": "value"
        },
        "options": {
            "returnEdits": "ALL"
        }
    }'

Response:

{"errorCode":"INVALID_ARGUMENT","errorName":"ApplyActionFailed","errorInstanceId":"e0280bfe-f28f-43e3-9152-5d27e80ff2ff","parameters":{}}

Is there some kind of enforcement of UUID values if the ontology detects a UUID scheme in existing rows?

I also created a variant of the application where my upsertState function was exposed as an action and called via workshop. I got some more detail,s and there is some kind of constraint violation.

Unknown Conjure Error

Error: [Actions] PropertyValueDoesNotMeetDataConstraints
Error ID: c02c944e-fe9f-4c1e-9214-881b4da24e54
Related values:
propertyTypeRid: ri.ontology.main.property.204e4ed0-50d5-48f3-8878-f76ce5a41427
propertyValue: Optional[Value{value: StringWrapper{value: 0822c4d4399066b61e484e841791aa8be7f03454ae06f573abce25c825a115a7}}]
failureMessage: Optional[Optional[Constraint failed]]

I rebuilt the dataset using uuid instead of a row hash and it resolved the errors I was getting. So for sure the ontology is enforcing UUIDs. I’m guessing this stems from the way the create action is setup.

Ontology has no opinions on the PK value content (as long as it is unique). What you are hitting below sounds like you may have configured the PK property type ri.ontology.main.property.204e4ed0-50d5-48f3-8878-f76ce5a41427 with a Value Type with uuid or regex constraint. Could this be the case?

2 Likes

Ahh, yes. I defined an ontology interface with this property type. I’ve attached a screenshot here in case anyone else stumbles on this issue.


. That explains it.