Hello,
I have a code repo function that retreives an object, calls my own api to perform an action (which seems like the hack that other people on here are doing), and then updates the object.
This generated an ObjectVersionChanged
error.
ad9b95f5-8dc5-4a28-bc9d-a27413669d76
if any palantir folks want to look it up.
AIP Assist explains this to be:
The
ObjectVersionChanged
error typically occurs when attempting to apply an Action to an object that has been modified since it was last retrieved. This error is part of Foundry’s concurrency control mechanism to prevent conflicting updates
This makes sense. So, to fix the bug, when I want to update the object, I now refetch it via:
const newlyFetchedObject= await Objects.search().myObject()
.filter(myObject => myObject.primaryKey_.exactMatch(previouslyFetchedObject.primaryKey_))
.allAsync();
newlyFetchedObject.myProperty = newValue;
This is still causing an ObjectVersionChanged
error to trigger.
I can’t recreate it in debug mode because, per the docs, debug mode shows me the edits that are authored, not committed. This error, I’m guessing, happens on commit.
Am I doing something wrong? Is there some sort of caching going on? Can I force it to get a fresh object reference?