# Error with composite query calls. All are being rejected

**URL:** <https://forum.dfinity.org/t/error-with-composite-query-calls-all-are-being-rejected/24762>\
**Category:** Language Support\
**Created:** [November 17, 2023, 1:29pm UTC](https://forum.dfinity.org/t/error-with-composite-query-calls-all-are-being-rejected/24762 "2023-11-17T13:29:54Z")\
**Posts on this page:** 11\
**Page:** 1

<div class="post-metadata">

**Author:** ![Jesse](https://sea1.discourse-cdn.com/flex023/user_avatar/forum.dfinity.org/jesse/32/37836_2.png) [@Jesse](https://forum.dfinity.org/u/Jesse)\
**Post date:** [November 17, 2023, 1:29pm UTC](https://forum.dfinity.org/t/error-with-composite-query-calls-all-are-being-rejected/24762/1 "2023-11-17T13:29:54Z")

</div>

I just implemented composite queries into my motoko code. When I attempt to call the `composite query` function, I’m getting the following error message:

```auto
Call failed:
Canister: hxx6x-baaaa-aaaap-qaaxq-cai
Method: getCanisterCyclesBalances (query)
"Status": "rejected"
"Code": "CanisterReject"
"Message": "Canister nl6hn-ja4yw-wvmpy-3z2jx-ymc34-pisx3-3cp5z-3oj4a-qzzny-jbsv3-4qe not found"

```

here is the code thats producing this error:

```auto
public composite query(msg) func getCanisterCyclesBalances() : async MainTypes.CanisterCyclesBalances{
        let backendCyclesBalance = Cycles.balance();
        let ic : IC.Self = actor "aaaaa-aa";
        let {cycles = frontendCyclesBalance } = await ic.canister_status({ canister_id = Principal.fromText(daoMetaData_v2.frontEndPrincipal) });
        return {frontendCyclesBalance; backendCyclesBalance };
    };

```

and here is the function signature for the `ic.canister_status` method that I’m calling:

```auto
public type Self = actor {
        canister_status : query { canister_id : canister_id } -> async canister_status_response;
};

```

can someone help me resolve this issue?

---

<div class="post-metadata">

**Author:** ![Vivienne](https://sea1.discourse-cdn.com/flex023/user_avatar/forum.dfinity.org/vivienne/32/29170_2.png) [@Vivienne](https://forum.dfinity.org/u/Vivienne)\
**Post date:** [November 17, 2023, 1:33pm UTC](https://forum.dfinity.org/t/error-with-composite-query-calls-all-are-being-rejected/24762/2 "2023-11-17T13:33:28Z")

</div>

You are asking for the canister status of `daoMetaData_v2.frontEndPrincipal`. It looks like this is the user’s principal, not a canister. Canister principals are much shorter than the one in the error message

---

<div class="post-metadata">

**Author:** ![Jesse](https://sea1.discourse-cdn.com/flex023/user_avatar/forum.dfinity.org/jesse/32/37836_2.png) [@Jesse](https://forum.dfinity.org/u/Jesse)\
**Post date:** [November 17, 2023, 1:38pm UTC](https://forum.dfinity.org/t/error-with-composite-query-calls-all-are-being-rejected/24762/3 "2023-11-17T13:38:17Z")

</div>

thanks for responding so fast @Vivienne. the principal in the error message is the Subnet’s principal ID. the value of `daoMetaData_v2.frontEndPrincipal` is `fkkq7-siaaa-aaaap-qaaya-cai`. I can confirm that it _is_ a canister principal.

I believe its calling the subnet’s principal because I defined the `ic` actor using `"aaaaa-aa"`. I’m guessing that when actors are defined using `"aaaaa-aa"`, the subnet’s principal is used as the acting principal.

also, I _do_ know that the issue isn’t with _that_ particular canister as I have tested other composite query functions where I make inter-canister query calls with a method from `rkp4c-7iaaa-aaaaa-aaaca-cai` (the Cycles Minting Canister) as the inner async method being called, and it returned the same error with `rkp4c-7iaaa-aaaaa-aaaca-cai` being the canister listed as `not found` within the error message.

---

<div class="post-metadata">

**Author:** ![Vivienne](https://sea1.discourse-cdn.com/flex023/user_avatar/forum.dfinity.org/vivienne/32/29170_2.png) [@Vivienne](https://forum.dfinity.org/u/Vivienne)\
**Post date:** [November 17, 2023, 1:44pm UTC](https://forum.dfinity.org/t/error-with-composite-query-calls-all-are-being-rejected/24762/4 "2023-11-17T13:44:20Z")

</div>

> [@Jesse](#):
>
> `nl6hn`

Ah, that’s possible… Let me ask the execution/runtime people about that… Could be something with composite queries not working as expected with the mgmt canister

---

<div class="post-metadata">

**Author:** ![stefan-kaestle](https://sea1.discourse-cdn.com/flex023/user_avatar/forum.dfinity.org/stefan-kaestle/32/3873_2.png) [@stefan-kaestle](https://forum.dfinity.org/u/stefan-kaestle)\
**Post date:** [November 17, 2023, 2:25pm UTC](https://forum.dfinity.org/t/error-with-composite-query-calls-all-are-being-rejected/24762/5 "2023-11-17T14:25:03Z")

</div>

Hi @Jesse,

The management canister’s `canister_status` is an update call. No update calls can be called from composite queries (only other composite queries and regular queries).

You can see the interface spec from the management canister [here](https://internetcomputer.org/docs/current/references/ic-interface-spec#ic-management-canister). There, you can see that the `canister_status` call is not declared a `query` (so it is implicitly an update call).

Hope this helps  
Stefan

---

<div class="post-metadata">

**Author:** ![Jesse](https://sea1.discourse-cdn.com/flex023/user_avatar/forum.dfinity.org/jesse/32/37836_2.png) [@Jesse](https://forum.dfinity.org/u/Jesse)\
**Post date:** [November 17, 2023, 4:22pm UTC](https://forum.dfinity.org/t/error-with-composite-query-calls-all-are-being-rejected/24762/6 "2023-11-17T16:22:36Z")

</div>

@stefan-kaestle, I’m also getting the same error when attempting to call other known query methods- namely, the `get_icp_xdr_conversion_rate` method within the cycles minting canister.

```auto
Call failed:
  Canister: hxx6x-baaaa-aaaap-qaaxq-cai
  Method: getCanisterData (query)
  "Status": "rejected"
  "Code": "CanisterReject"
  "Message": "Canister rkp4c-7iaaa-aaaaa-aaaca-cai not found"

```

I confirmed that the method is a query method via the icp dashboard (see screenshot below)

 ![Screenshot 2023-11-17 at 10.31.57 AM](https://us1.discourse-cdn.com/flex023/uploads/dfn/original/2X/3/328c6027357af56e8829d67ae196a5df0536dfb1.png)

---

<div class="post-metadata">

**Author:** ![stefan-kaestle](https://sea1.discourse-cdn.com/flex023/user_avatar/forum.dfinity.org/stefan-kaestle/32/3873_2.png) [@stefan-kaestle](https://forum.dfinity.org/u/stefan-kaestle)\
**Post date:** [November 17, 2023, 4:54pm UTC](https://forum.dfinity.org/t/error-with-composite-query-calls-all-are-being-rejected/24762/7 "2023-11-17T16:54:46Z")

</div>

Could you send the code for that call as well.

One restrictions with composite queries is that they don’t work across subnetworks. `rkp4c-7iaaa-aaaaa-aaaca-cai` is the [cycles miniting canister](https://dashboard.internetcomputer.org/canister/rkp4c-7iaaa-aaaaa-aaaca-cai), which is in the NNS subnetwork. So that could be the problem?

---

<div class="post-metadata">

**Author:** ![Jesse](https://sea1.discourse-cdn.com/flex023/user_avatar/forum.dfinity.org/jesse/32/37836_2.png) [@Jesse](https://forum.dfinity.org/u/Jesse)\
**Post date:** [November 17, 2023, 4:59pm UTC](https://forum.dfinity.org/t/error-with-composite-query-calls-all-are-being-rejected/24762/8 "2023-11-17T16:59:33Z")

</div>

That most certainly is the problem. Thats good to know.

---

<div class="post-metadata">

**Author:** ![Jesse](https://sea1.discourse-cdn.com/flex023/user_avatar/forum.dfinity.org/jesse/32/37836_2.png) [@Jesse](https://forum.dfinity.org/u/Jesse)\
**Post date:** [November 17, 2023, 11:53pm UTC](https://forum.dfinity.org/t/error-with-composite-query-calls-all-are-being-rejected/24762/9 "2023-11-17T23:53:26Z")

</div>

> [@stefan-kaestle](#):
>
> One restrictions with composite queries is that they don’t work across subnetworks.

@stefan-kaestle this raises a question. I have some canisters that are programmatically deployed by my `main.mo ` canister. At no point do I specify which subnet they are to be deployed to. Is a child canister guaranteed to be deployed to the same subnet as the parent canister that deployed it?

---

<div class="post-metadata">

**Author:** ![h1teshtr1path1](https://sea1.discourse-cdn.com/flex023/user_avatar/forum.dfinity.org/h1teshtr1path1/32/24662_2.png) [@h1teshtr1path1](https://forum.dfinity.org/u/h1teshtr1path1)\
**Post date:** [November 18, 2023, 5:59am UTC](https://forum.dfinity.org/t/error-with-composite-query-calls-all-are-being-rejected/24762/10 "2023-11-18T05:59:24Z")

</div>

Yes, a canister always makes new canisters in same subnet.

---

<div class="post-metadata">

**Author:** ![claudio](https://sea1.discourse-cdn.com/flex023/user_avatar/forum.dfinity.org/claudio/32/322_2.png) [@claudio](https://forum.dfinity.org/u/claudio)\
**Post date:** [November 24, 2023, 5:05pm UTC](https://forum.dfinity.org/t/error-with-composite-query-calls-all-are-being-rejected/24762/11 "2023-11-24T17:05:12Z")

</div>

For this particular call, the error is that canister\_status is not a query method, so you should instead declare it with this type:

```auto
public type Self = actor {
        canister_status : { canister_id : canister_id } -> async canister_status_response;
};

```

(omitting `query`).

(See [The Internet Computer Interface Specification | Internet Computer](https://internetcomputer.org/docs/current/references/ic-interface-spec#ic-management-canister) - if `canister_status` were a query, it would have a Candid `query` keyword at the end of the Candid function type.)
