Closed githubdoramon closed 1 year ago
I think there is some wrong with user and sync: tables users
, syncs
and synced_issues
are empty. (Tables linear_teams
and github_repos
have some data which makes sense.)
Webhooks are installed in both Github and Linear, but webhook in github repo always gets 404 error from synclinear/api:
{"success":false,"message":"Could not find sync for matter-labs/era-test-node"}
Also when I try to add a team from Linear I got error popup:
"error": "Failed to save sync with error: \nInvalid
prisma.sync.upsert()invocation:\n\n\nError occurred during query execution:\nConnectorError(ConnectorError { user_facing_error: None, kind: QueryError(Error { kind: Db, cause: Some(DbError { severity: \"ERROR\", parsed_severity: Some(Error), code: SqlState(E42P10), message: \"there is no unique or exclusion constraint matching the ON CONFLICT specification\", detail: None, hint: None, position: None, where_: None, schema: None, table: None, column: None, datatype: None, constraint: None, file: Some(\"plancat.c\"), line: Some(860), routine: Some(\"infer_arbiter_indexes\") }) }), transient: false })"
So looks like database schema has some conflicts.
Also from our database logs:
STATEMENT: INSERT INTO "public"."syncs" ("id","githubUserId","linearUserId","githubRepoId","githubApiKey","githubApiKeyIV","linearTeamId","linearApiKey","linearApiKeyIV") VALUES ($1,$2,$3,$4,$5,$6,$7,$8,$9) ON CONFLICT ("githubUserId","linearUserId","githubRepoId","linearTeamId") DO UPDATE SET "githubApiKey" = $10, "githubApiKeyIV" = $11, "linearApiKey" = $12, "linearApiKeyIV" = $13 WHERE (("public"."syncs"."githubUserId" = $14 AND "public"."syncs"."linearUserId" = $15 AND "public"."syncs"."githubRepoId" = $16 AND "public"."syncs"."linearTeamId" = $17) AND 1=1) RETURNING "public"."syncs"."id", "public"."syncs"."githubUserId", "public"."syncs"."linearUserId", "public"."syncs"."githubRepoId", "public"."syncs"."githubApiKey", "public"."syncs"."githubApiKeyIV", "public"."syncs"."linearTeamId", "public"."syncs"."linearApiKey", "public"."syncs"."linearApiKeyIV"
ERROR: there is no unique or exclusion constraint matching the ON CONFLICT specification
Looks like block https://github.com/calcom/synclinear.com/blob/7cba738cf777cf41616eb1701a621a1f9a0a98b9/pages/api/save.ts#L61-L66 must have uniq index.
Looks like adding unique index like following helps:
create unique index concurrently ix_syncs_t1 on "public"."syncs" ("githubUserId","linearUserId","githubRepoId","linearTeamId");
But it should be done automatically by prism: https://github.com/calcom/synclinear.com/blame/7cba738cf777cf41616eb1701a621a1f9a0a98b9/prisma/schema.prisma#L81C71-L81C71
I wonder why it's missing in migrations...
I've deployed a self-hosted version, and deployed the webhooks, but it doesn't seem to work (no issues are created or synced).
What is the right way to start debugging this? How to check what hooks are actually deployed? Or which logs/tables to check for errors?