Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

wgc commands are failing #592

Closed
ricardogoncalvesmindera opened this issue Mar 1, 2024 · 9 comments
Closed

wgc commands are failing #592

ricardogoncalvesmindera opened this issue Mar 1, 2024 · 9 comments
Labels
intended behavior The issue was determined to be intended behavior. internally-reviewed The issue has been reviewed internally. resolved The issue was resolved.

Comments

@ricardogoncalvesmindera
Copy link

ricardogoncalvesmindera commented Mar 1, 2024

Component(s)

cli

Component version

latest

wgc version

latest

controlplane version

latest

router version

latest

What happened?

Since a few days ago i'm not able to run any wgc commands, i get the following error:

/app # wgc federated-graph update qa --label-matcher env=qa --routing-url https://graphql-qa.com/cosmo/v1/graphql ConnectError: [internal] internal error at errorFromJson (file:///usr/local/lib/node_modules/wgc/node_modules/@connectrpc/connect/dist/esm/protocol-connect/error-json.js:54:19) at errorFromJsonBytes (file:///usr/local/lib/node_modules/wgc/node_modules/@connectrpc/connect/dist/esm/protocol-connect/error-json.js:93:12) at next (file:///usr/local/lib/node_modules/wgc/node_modules/@connectrpc/connect/dist/esm/protocol-connect/transport.js:113:31) at process.processTicksAndRejections (node:internal/process/task_queues:95:5) at async Object.unary (file:///usr/local/lib/node_modules/wgc/node_modules/@connectrpc/connect/dist/esm/protocol-connect/transport.js:63:20) at async Object.updateFederatedGraph (file:///usr/local/lib/node_modules/wgc/node_modules/@connectrpc/connect/dist/esm/promise-client.js:67:26) at async Command.<anonymous> (file:///usr/local/lib/node_modules/wgc/dist/commands/federated-graph/commands/update.js:27:22) at async Command.parseAsync (/usr/local/lib/node_modules/wgc/node_modules/commander/lib/command.js:936:5) at async file:///usr/local/lib/node_modules/wgc/dist/index.js:8:5 { rawMessage: 'internal error', code: 13, metadata: HeadersList { cookies: null, [Symbol(headers map)]: Map(8) { 'access-control-allow-credentials' => [Object], 'access-control-expose-headers' => [Object], 'connection' => [Object], 'content-length' => [Object], 'content-type' => [Object], 'date' => [Object], 'keep-alive' => [Object], 'vary' => [Object] }, [Symbol(headers map sorted)]: null }, details: [], cause: undefined }

This happens in the cosmo running in our infrastructure and also on cosmo running from the example locally.

Environment information

No response

Router configuration

No response

Router execution config

No response

Log output

No response

Additional context

No response

@ricardogoncalvesmindera ricardogoncalvesmindera added the bug Something isn't working label Mar 1, 2024
Copy link

github-actions bot commented Mar 1, 2024

WunderGraph commits fully to Open Source and we want to make sure that we can help you as fast as possible.
The roadmap is driven by our customers and we have to prioritize issues that are important to them.
You can influence the priority by becoming a customer. Please contact us here.

@Aenimus
Copy link
Member

Aenimus commented Mar 2, 2024

Hi @ricardogoncalvesmindera,

I think this might be the same issue as #582.

Please makes sure you're using Node 18+.

@thisisnithin
Copy link
Member

thisisnithin commented Mar 4, 2024

Hi, if you are self hosting the controlplane as well, you should see relevant errors there. Please send that as well, else it is difficult to debug. Thank you.

@Aenimus Aenimus added the internally-reviewed The issue has been reviewed internally. label Mar 4, 2024
@ricardogoncalvesmindera
Copy link
Author

I did another testing locally, the problem seems to be on creating subgraphs, here's some info:

Screenshot 2024-03-04 at 10 27 39

Logs on control plane:

`
2024-03-04 10:26:49 {"level":"info","time":"2024-03-04T10:26:49.616Z","pid":1,"hostname":"a325607512bb","reqId":"req-3","req":{"method":"POST","url":"/wg.cosmo.platform.v1.PlatformService/CreateFederatedSubgraph","hostname":"localhost:3001","remoteAddress":"192.168.65.1","remotePort":37810},"msg":"incoming request"}
2024-03-04 10:26:49 Query: select "apiKeys"."id", "apiKeys"."user_id", "apiKeys"."organization_id", "apiKeys"."name", "apiKeys"."key", "apiKeys"."last_used_at", "apiKeys"."created_at", "apiKeys"."expires_at", "apiKeys_user"."data" as "user" from "api_keys" "apiKeys" left join lateral (select json_build_array("apiKeys_user"."id", "apiKeys_user"."email", "apiKeys_user"."created_at") as "data" from (select * from "users" "apiKeys_user" where "apiKeys_user"."id" = "apiKeys"."user_id" limit $1) "apiKeys_user") "apiKeys_user" on true where "apiKeys"."key" = $2 limit $3 -- params: [1, "cosmo_669b576aaadc10ee1ae81d9193425705", 1]
2024-03-04 10:26:49 Query: select "id", "name", "slug", "user_id", "created_at", "is_free_trial" from "organizations" where "organizations"."id" = $1 limit $2 -- params: ["ddd791ff-4577-4636-9db9-0ff05b6d8224", 1]

2024-03-04 10:26:49 Query: update "api_keys" set "last_used_at" = $1 where "api_keys"."id" = $2 -- params: ["Mon, 04 Mar 2024 10:26:49 GMT", "36431c3f-794d-42a9-9622-fc73a3bb89fa"]

2024-03-04 10:26:49 Query: select "targets"."id", "targets"."name", "targets"."type", "targets"."created_at", "targets"."labels", "targets"."organization_id", "targets_subgraph"."data" as "subgraph" from "targets" left join lateral (select json_build_array("targets_subgraph"."id", "targets_subgraph"."routing_url", "targets_subgraph"."subscription_url", "targets_subgraph"."subscription_protocol", "targets_subgraph"."schema_version_id", "targets_subgraph"."target_id", "targets_subgraph_schemaVersion"."data") as "data" from (select * from "subgraphs" "targets_subgraph" where "targets_subgraph"."target_id" = "targets"."id" limit $1) "targets_subgraph" left join lateral (select json_build_array("targets_subgraph_schemaVersion"."id", "targets_subgraph_schemaVersion"."target_id", "targets_subgraph_schemaVersion"."schema_sdl", "targets_subgraph_schemaVersion"."is_composable", "targets_subgraph_schemaVersion"."composition_errors", "targets_subgraph_schemaVersion"."router_config", "targets_subgraph_schemaVersion"."created_at") as "data" from (select * from "schema_versions" "targets_subgraph_schemaVersion" where "targets_subgraph_schemaVersion"."id" = "targets_subgraph"."schema_version_id" limit $2) "targets_subgraph_schemaVersion") "targets_subgraph_schemaVersion" on true) "targets_subgraph" on true where ("targets"."name" = $3 and "targets"."organization_id" = $4 and "targets"."type" = $5) limit $6 -- params: [1, 1, "javagraph", "ddd791ff-4577-4636-9db9-0ff05b6d8224", "subgraph", 1]

2024-03-04 10:26:49 Query: insert into "targets" ("id", "name", "type", "created_at", "labels", "organization_id") values (default, $1, $2, default, $3, $4) returning "id", "name", "type", "created_at", "labels", "organization_id" -- params: ["javagraph", "subgraph", "{}", "ddd791ff-4577-4636-9db9-0ff05b6d8224"]
2024-03-04 10:26:49 Query: insert into "subgraphs" ("id", "routing_url", "subscription_url", "subscription_protocol", "schema_version_id", "target_id") values (default, $1, $2, $3, default, $4) returning "id", "routing_url", "subscription_url", "subscription_protocol", "schema_version_id", "target_id" -- params: ["http://localhost:5001/graph/v3/query", "ws://localhost:5001/graph/v3/subscriptions", "ws", "3309fa8b-83ab-4c5c-8a6f-6ba78ad5a706"]
2024-03-04 10:26:49 Query: select "targets"."name" from "targets" inner join "federated_graphs" on "federated_graphs"."target_id" = "targets"."id" left join "schema_versions" on "schema_versions"."id" = "federated_graphs"."composed_schema_version_id" where ("targets"."organization_id" = $1 and "targets"."type" = $2 and not exists ((select "target_id", "label_matcher" from "target_label_matchers" where ("target_label_matchers"."target_id" = "targets"."id" and not label_matcher && ARRAY[])))) order by "targets"."created_at" asc, "schema_versions"."created_at" asc -- params: ["ddd791ff-4577-4636-9db9-0ff05b6d8224", "federated"]

2024-03-04 10:26:49 {"level":"error","time":"2024-03-04T10:26:49.648Z","pid":1,"hostname":"a325607512bb","service":"wg.cosmo.platform.v1.PlatformService","method":"CreateFederatedSubgraph","err":{"type":"PostgresError","message":"cannot determine type of empty array","stack":"PostgresError: cannot determine type of empty array\n at ErrorResponse (file:///app/node_modules/.pnpm/postgres@3.4.3/node_modules/postgres/src/connection.js:790:26)\n at handle (file:///app/node_modules/.pnpm/postgres@3.4.3/node_modules/postgres/src/connection.js:476:6)\n at Socket.data (file:///app/node_modules/.pnpm/postgres@3.4.3/node_modules/postgres/src/connection.js:315:9)\n at Socket.emit (node:events:517:28)\n at addChunk (node:internal/streams/readable:335:12)\n at readableAddChunk (node:internal/streams/readable:308:9)\n at Readable.push (node:internal/streams/readable:245:10)\n at TCP.onStreamRead (node:internal/stream_base_commons:190:23)","name":"PostgresError","severity_local":"ERROR","severity":"ERROR","code":"42P18","hint":"Explicitly cast to the desired type, for example ARRAY[]::integer[].","position":"458","file":"parse_expr.c","line":"1995","routine":"transformArrayExpr"},"msg":"cannot determine type of empty array"}

2024-03-04 10:26:49 {"level":"info","time":"2024-03-04T10:26:49.650Z","pid":1,"hostname":"a325607512bb","reqId":"req-3","res":{"statusCode":500},"responseTime":33.873875000019325,"msg":"request completed"}
`

@Aenimus
Copy link
Member

Aenimus commented Mar 4, 2024

@ricardogoncalvesmindera what are the outputs of "which wgc" and "which node"?

@ricardogoncalvesmindera
Copy link
Author

I found out the issue, the create subgraph command is missing the label option, if i add the --label env=qa the command work. I didn't know it was mandatory.

@ricardogoncalvesmindera
Copy link
Author

You can close it as non-issue. Thank you and sorry for the time you spent.

@Aenimus
Copy link
Member

Aenimus commented Mar 4, 2024

Hi @ricardogoncalvesmindera

It is no longer necessary to include labels in federated graphs or subgraphs. However, if your federated graph was already created with labels, its constituent subgraphs must match that label.

But please also note that if you choose not to use labels, all federated graphs within that namespace will be composed with the same (unlabeled) subgraphs. The only difference between the federated graphs will be the routing URL.

Sorry for the confusion.

@Aenimus Aenimus closed this as completed Mar 4, 2024
@Aenimus Aenimus added intended behavior The issue was determined to be intended behavior. resolved The issue was resolved. and removed bug Something isn't working labels Mar 4, 2024
@thisisnithin
Copy link
Member

thisisnithin commented Mar 5, 2024

Hi @ricardogoncalvesmindera. Seems you are not on the latest version of the control plane (although in the issue you have specified it as so) but your CLI is. Please upgrade so you don't face compatibility issues like these and take care to specify the correct version in the issue.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
intended behavior The issue was determined to be intended behavior. internally-reviewed The issue has been reviewed internally. resolved The issue was resolved.
Projects
None yet
Development

No branches or pull requests

3 participants