Composite_query declarations generation from candid fails

It seems that there is something not right when using composite_query for generating bindings from candid.

You can check it here → Internet Computer Loading
To confirm, on https://dashboard.internetcomputer.org/canister/canister-id it also throws an error.

This candid is invalid and gives an Error generating bindings for the Candid interface.

service : {
  foo: (principal) -> (text) composite_query;
}

Where this functions as expected

service : {
  foo: (principal) -> (text) query;
}

As a hacky method we deploy the canister with the methods marked as query and and once deployed do an install so the wasm gets generated with composite_query without changed the candid file.

3 Likes

If you use the latest didc (in this repo) it works. Looks like Canlista doesn’t have the latest version of candid.

@Ori are you the owner of Canlista?

2 Likes

I guess this change also needs to be implemented on the dashboard then?
for example here; Canister: swone-5aaaa-aaaak-ae7za-cai - ICP Dashboard

2 Likes

Thanks. It does need an update, I’ll bump that for you. It uses a slightly modified wasm build of the didc source.

2 Likes

Done. That should now generate the binding correctly!

2 Likes

@Dylan The composite query candid generation is still an issue on the dashboard, for example

Thanks for flagging. I didn’t see this thread earlier.

1 Like

I’m having this same issue. and unfortunately, I’m not gonna be able to resolve it using the hack that @RMCS mentioned since the composite_query methods that I have are methods are defined within actor class files. Replicating RMCS’s hack would require me to add a lot of code that’ll become unnecessary once this bug has been resolved.

@Dylan do you have an estimated time of completion for this particular bug?

@Severin how do I upgrade the candid version I’m using? Is there as CLI command for it?

Hi @Jesse, I can only speak for the problem on the ICP Dashboard. We’ll release a fix for this tomorrow.

The code does deploy with the composite queries, right?

What I do now (to get the correct frontend declarations) is copy the candid from the internet computer dashboard, paste it in canlista en then cope the correct declarations in the language of choice.

For the js/ts declarations this also means that you need to manually change “composite_query” to “query” because js agent 0.19.3 doesn’t support composite queries as wel (it works after changing this) Pinged @kpeacock about this issue.

1 Like

This is actually a candid codegen issue that will need to be rolled out in dfx and the didc tool. If your IDL flags the method as composite_query the agent works as intended

The ICP Dashboard fix for composite queries has been released.

2 Likes

@kpeacock do you have an estimate of how soon a fix may be released? and in the meantime, is there a solution that I can implement so that I can carry on developing? the hack that @RMCS mentioned only works for me when I deploy locally, but when attempting to deploy my user interface to the IC, the hack is no longer effective.

@Severin mentioned that the latest didc version tooling works. I haven’t been able to confirm as I’m unaware of how I would go about installing the didc CLI to my machine. Is there some package manager that I could use to do so? I’ve check the README file for the didc tool, but it makes no mention of how to go about installing the tool.

for more context. Below is the error, request and response thats being displayed in the browser console when a composite query method is called. None of it was very informative for me, but maybe you all can spot something I missed. This bug is particularly challenging to investigate because it only shows up when deployed to the IC. So I’m unable to use the dev tools that are present when testing locally.

sw.ts:64 Error 
error @ sw.ts:64
(anonymous) @ sw.ts:64
UQ @ sw.ts:64
(anonymous) @ sw.ts:64
await in (anonymous) (async)
(anonymous) @ sw.ts:64

Request {method: 'POST', url: 'https://ic0.app/api/v2/canister/hxx6x-baaaa-aaaap-qaaxq-cai/read_state', headers: Headers, destination: '', referrer: 'https://fkkq7-siaaa-aaaap-qaaya-cai.icp0.io/', …}
body
: 
(...)
bodyUsed
: 
true
cache
: 
"reload"
credentials
: 
"same-origin"
destination
: 
""
headers
: 
Headers {}
integrity
: 
""
isHistoryNavigation
: 
false
keepalive
: 
false
method
: 
"POST"
mode
: 
"cors"
redirect
: 
"follow"
referrer
: 
"https://fkkq7-siaaa-aaaap-qaaya-cai.icp0.io/"
referrerPolicy
: 
"strict-origin-when-cross-origin"
signal
: 
AbortSignal {aborted: false, reason: undefined, onabort: null}
url
: 
"https://ic0.app/api/v2/canister/hxx6x-baaaa-aaaap-qaaxq-cai/read_state"

Response {type: 'default', url: '', redirected: false, status: 400, ok: false, …}
body
: 
(...)
bodyUsed
: 
false
headers
: 
Headers {}
ok
: 
false
redirected
: 
false
status
: 
400
statusText
: 
""
type
: 
"default"
url
: 
""

when I perform a try / catch and print the error, this is what prints up:

Error: Server returned an error:
  Code: 502 ()
  Body: 

    at G.readState (index.js:2:327583)
    at async ie (index.js:2:405875)
    at async o (index.js:2:410516)
    at async index.js:205:1358226

@Jesse, to install didc you can download a prebuilt binary here

1 Like

@Severin after downloading the binary, are there any further things i need to do to install it? Or Is there a specific directory that i need to download the binary to?

No, it just needs to be on your PATH somewhere. And you may have to make it executable

1 Like