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

Error creating link #750

Open
daniel-sockness opened this issue Jun 17, 2024 · 1 comment
Open

Error creating link #750

daniel-sockness opened this issue Jun 17, 2024 · 1 comment

Comments

@daniel-sockness
Copy link

daniel-sockness commented Jun 17, 2024

When using the api from xyz.com/api/v2/links

With the following request

curl --location 'https://xyz.com/api/v2/links' \ --header 'X-API-KEY: apikey' \ --header 'Content-Type: application/json' \ --data '{ "target": "test.com", "customurl": "123", "reuse": true, "domain": "xyz.com" }'

I get the following error it also occurs if I create it from the web page

fatal Error: Undefined binding(s) detected when compiling FIRST. Undefined column(s): [domain_id] query: select "links"."id", "links"."address", "links"."banned", "links"."created_at", "links"."domain_id", "links"."updated_at", "links"."password", "links"."description", "links"."expire_in", "links"."target", "links"."visit_count", "links"."user_id", "links"."uuid", "domains"."address" as "domain" from "links" left join "domains" on "links"."domain_id" = "domains"."id" where "target" = ? and "domain_id" = ? and "links"."user_id" = ? limit ? at QueryCompiler_PG.toSQL (/home/kutt/node_modules/knex/lib/query/querycompiler.js:112:13) at QueryBuilder_PostgreSQL.toSQL (/home/kutt/node_modules/knex/lib/query/querybuilder.js:84:44) at ensureConnectionCallback (/home/kutt/node_modules/knex/lib/execution/internal/ensure-connection-callback.js:4:30) at Runner.ensureConnection (/home/kutt/node_modules/knex/lib/execution/runner.js:318:20) at runMicrotasks (<anonymous>) at processTicksAndRejections (internal/process/task_queues.js:97:5) at async Runner.run (/home/kutt/node_modules/knex/lib/execution/runner.js:30:19) at async Object.find (/home/kutt/production-server/queries/link.js:100:18) at async Promise.all (index 3) at async create (/home/kutt/production-server/handlers/links.js:67:21)

I have also tried using both the postgres id for the domain as well as the uuid in the domain table.

@hammady
Copy link

hammady commented Oct 10, 2024

I am facing the same issue after upgrading from 2.7.2 (not found in the github releases anymore, but I was using the docker hub image). There are tons of changes since then, but I spotted the issue.
Basically this code will load the domain from the database and replace the bare string in the request body with the full domain object. Later on in the links handler, it tries to access the id of the domain object to use it in subsequent queries. According to this SO thread the parameter cannot be undefined and hence the error message. It seems that replacing the domain string with the object in the request object doesn't work anymore and I wonder why no one else is complaining! It consistently happens when the request has both a domain and custom address.

I temporarily fixed it by hardcoding the domain_id to 1 which is the only domain we have.

I'm not a TS developer anyway and don't have more time to spend on this, so let's hope v3 is out soon!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants