digital-asset / daml

The Daml smart contract language
https://www.digitalasset.com/developers
797 stars 199 forks source link

JSON API create and query endpoints fail for payload which works with http json 2.8.8 #19544

Open dasormeter opened 2 months ago

dasormeter commented 2 months ago

i think we’ve found a blocker regression with http json api : existing /v1/create and /v1/query payloads are failing with http json version 2.9.0-snapshot.20240627.12859.1.v8721b34e (the one referenced from https://github.com/digital-asset/daml/releases/tag/v2.9.0-rc2) (edited)

The same payload works successfully with http json 2.8.8-by-20240627.544.v08ba297d

it looks like it is now enforcing the Package ID format, but i wouldn’t expect this would be a hard breaking change in a minor release?

REQUEST

https://{host}/v1/create
{
  "templateId": "Chat.V3:UserAccountRequest",
  "payload": {
    "operator": "useradmin::122040878a77fb6f6646f3473fa96411b73ed15b428a4472986cc97d4df0d39f855a",
    "user": "ledger-party-8c0b5851-ee3f-4416-8b56-719deb751f78::122040878a77fb6f6646f3473fa96411b73ed15b428a4472986cc97d4df0d39f855a",
    "userName": "jimmy.jam"
  }
}

response { "errors": [ "JsonError: DomainJsonDecoder_decodeCreateCommand JsonReaderError. Cannot read JSON: <{\"payload\":{\"operator\":\"useradmin::1220a0c30fed7b3799f56a5daea8b83eeb000ed4e69a380a53d8fe8dccbfb5418e97\",\"user\":\"ledger-party-155f6d09-5177-44eb-bdca-031d9a29db6f::1220a0c30fed7b3799f56a5daea8b83eeb000ed4e69a380a53d8fe8dccbfb5418e97\",\"userName\":\"brian.healey\"},\"templateId\":\"Chat.V3:UserAccountRequest\"}>. Cause: spray.json.DeserializationException: Expected JsString(<packageId>:<module>:<entity>), got: \"Chat.V3:UserAccountRequest\". did not have two ':' chars" ], "status": 400 }

and similar error for a /v1/query request as well

REQUEST

https://{host}/v1/query
{
  "templateIds": [
    "Chat.V3:User",
    "Chat.V3:UserInvitation"
  ]
}

response { "errors": [ "JsonReaderError. Cannot read JSON: <{\"templateIds\":[\"Chat.V3:User\",\"Chat.V3:UserInvitation\"]}>. Cause: spray.json.DeserializationException: Expected JsString(<packageId>:<module>:<entity>), got: \"Chat.V3:User\". did not have two ':' chars" ], "status": 400 }

dasormeter commented 2 months ago

From the http json api 2.9.0 docs it states that : should still be a valid identifier for templateId in addition to :: provided there is only one template across all loaded packages https://docs.daml.com/2.9.0/json-api/index.html#http-request

image