Unauthorized Tasks?
Hey all, facing an issue where I can't seem to get any task working when using the workflows as code setup. It just keeps returning unauthorized. The tool works without the tasks.
=======
job=0191fb5d-fe4f-0926-43e4-be56644dc4b6 tag=bun worker=wk-reports-3306192d8b44-hZzbM hostname=3306192d8b44
skipping install, using cached buntar based on lockfile hash: K_HkMUcdUDKK88MuEFqRQSyII2agWOINYHUOoXlP-vU=
--- BUN CODE EXECUTION ---
Started task crawlPageWithFetch as job Unauthorized
Error crawling https://example.com: 1 | "use strict";
2 | Object.defineProperty(exports, "__esModule", { value: true });
3 | exports.ApiError = void 0;
4 | class ApiError extends Error {
5 | constructor(request, response, message) {
6 | super(message);
^
ApiError: Bad Request
url: "http://127.0.0.1:44029/api/w/no_workspace/jobs_u/completed/get_result_maybe/Unauthorized"
at new ApiError (/tmp/windmill/wk-reports-3306192d8b44-hZzbM/0191fb5d-fe4f-0926-43e4-be56644dc4b6/node_modules/windmill-client/dist/core/ApiError.js:6:9)
at catchErrorCodes (/tmp/windmill/wk-reports-3306192d8b44-hZzbM/0191fb5d-fe4f-0926-43e4-be56644dc4b6/node_modules/windmill-client/dist/core/request.js:224:15)
at /tmp/windmill/wk-reports-3306192d8b44-hZzbM/0191fb5d-fe4f-0926-43e4-be56644dc4b6/node_modules/windmill-client/dist/core/request.js:269:29
at fulfilled (/tmp/windmill/wk-reports-3306192d8b44-hZzbM/0191fb5d-fe4f-0926-43e4-be56644dc4b6/node_modules/windmill-client/dist/core/request.js:5:58)
9 Replies
the call to create jobs is returning not authorized
you should print the env variabes to check if everything is in order for the WM_WORKSPACE and WM_TOKEN and WM_BASE_URL and BASE_URL
Debugging now. Finding out it doesn't run without task either now haha
They all are set and appear to be set correctly. More concerningly I'm not seeming to get it to run via the UI either which I've logged in/out on.
The only one that seems a little out of place on local dev is the baseurl which points to localhost... which appears to be proxying or something.
BASE_URL: "http://127.0.0.1:43627",
WM_BASE_URL: "https://windmill.mydomain.com",
WMTOKEN: "jwt"
WM_WORKSPACE: "providers"
The strange thing is that is returning successful from that in the UI
print that:
(add it to your main, deploy, and run it from UI)
hmm you're not using a cached bundle
that can't be the cause
either you're clearing your env somewhere or importing the wmill library wrong
Deploying now to test those
anyway, the issue is that the wmill client isn't picking up the token and workspace from env
On the server, token WM_TOKEN prints fine, but can't find
wmill
it's assuming you're importing it as
import * as wmill from "windmill-client"
Got ya
OK. Will test
On the server:
Started task crawlPageWithFetch as job Unauthorized
when logging wmill, JWT is there and matches the token logged from the process.env
OK, one of the script I was importing had side effects which messed with the global.document and global.window. Disabling that script fixed it.
Thanks @rubenf