When trying to push functions from Gitlab CI (with an API KEY and using the CLI), i saw that i was unable to push functions.
$ appwrite client --endpoint $APPWRITE_ENDPOINT --project-id $APPWRITE_PROJECT_ID --key $APPWRITE_API_KEY
✓ Success: Client configuration updated
$ appwrite push functions --function-id $APPWRITE_FUNCTION_ID --force --activate true
ℹ Info: Validating functions ...
ℹ Info: Checking for changes ...
ℹ Info: Pushing functions ...
ℹ Info: For detailed error pass the --verbose or --report flag
✗ Error: Session not found. Please run `appwrite login` to create a session
Is it something that you stopped supporing or is it a bug ?
Looking at the code, it seams like the push function uses the ConsoleService for checking proxies rules :
- https://github.com/appwrite/sdk-for-cli/blob/22.3.0/lib/commands/push.ts#L827
- https://github.com/appwrite/sdk-for-cli/blob/master/lib/commands/init.ts#L388
- https://github.com/appwrite/sdk-for-cli/blob/master/lib/sdks.ts#L89
which means the SDK for console have
requireAuthtotrueand so require either an access token OR a cookie.
As a fix, maybe :
- when pushing functions/site to add an option for the proxy part (like a
--with-proxies) - just skip that proxy part if it's an API KEY
- or since i saw in the console, that the API keys have proxy scopes, to fix it and don't use the ConsoleService
as a current workaround i'm using the login with totp :
$ npm i -g totp-client
$ export TOTP=$(totp-client generate $APPWRITE_TOTP_SECRET | sed -n 's/.*TOTP Code: \([0-9]*\).*/\1/p') && echo $TOTP
XXXXXX
$ appwrite login --endpoint $APPWRITE_ENDPOINT --email $APPWRITE_EMAIL --password $APPWRITE_PASSWORD --mfa totp --code $TOTP
✓ Success: Successfully signed in as ibaraki@example.Com
♥ Hint: Next you can create or link to your project using 'appwrite init project'
$ appwrite push functions --function-id $APPWRITE_FUNCTION_ID --force --activate true
ℹ Info: Validating functions ...
ℹ Info: Checking for changes ...
ℹ Info: Pushing functions ...
........
✓ Success: Successfully deployed 1 function in 50.4s.
it's just annoying cuz every publish i get an email warning me about a new sessions xdd
taking a look
saw it was merged and deployed, i'm testing
sadly still not working
it's more like the push command constructor have the console that needs session and is used in places where it should be key only
using this console client : https://github.com/appwrite/sdk-generator/blob/main/templates/cli/lib/commands/push.ts#L782
this is the actual release - https://github.com/appwrite/sdk-for-cli/pull/337
oh ok ok, iirc i saw it in the 22.5.0 release note but might be wrong
Also, it's now working
$ appwrite client --endpoint $APPWRITE_ENDPOINT --project-id $APPWRITE_PROJECT_ID --key $APPWRITE_API_KEY
✓ Success: Client configuration updated
$ appwrite push functions --function-id $APPWRITE_FUNCTION_ID --force --activate true
ℹ Info: Validating functions ...
ℹ Info: Checking for changes ...
ℹ Info: Pushing functions ...
⠧ Pushing • Template (688373db001c98838edf) • Ignoring using: appwrite.config.json
⠴ Deploying • Template (688373db001c98838edf) • Status: waiting
⠇ Deploying • Template (688373db001c98838edf) • Status: building
Build logs
⠦ Deploying • Template (688373db001c98838edf) • Status: building
⠼ Deploying • Template (688373db001c98838edf) • Status: building
⠹ Deploying • Template (688373db001c98838edf) • Status: building
⠏ Deploying • Template (688373db001c98838edf) • Status: building
⠧ Deploying • Template (688373db001c98838edf) • Status: building
⠦ Deploying • Template (688373db001c98838edf) • Status: building
✓ Deployed • Template (688373db001c98838edf)
ℹ Info: Preview link: https://6a4f82fa0015e9b31ca3.appwrite.example.com
ℹ Info: Deployment page: https://appwrite.example.com/console/project-688228a50003cf2546fa/functions/function-688373db001c98838edf/deployment-6a50af6fc2c21b17a951
✓ Success: Successfully deployed 1 function in 49.7s.
noice
putting it as solved
[SOLVED] Unable to push function from API KEY with CLI
also when pushing, the Deployment page URL use project-688228a50003cf2546fa tho the console use regions so it should be project-default-688228a50003cf2546fa instead
since i don't use that URL i don't really care, but for others that could be nice to fix it
ur using self hosted?
yes (that's why it's using default and not a real region)
yep yep makes sense
noted
i swear it used to be just project-${projectId} for self hosted, there is logic for it
ig it changed with 1.9.5?
no it was already the case since the cloud regions so something like 1.8.0.
i also remember needing a console patch because the console didn't support region when the API did
for example, the "/v1/account/prefs" return this, so with the region
Recommended threads
- Function's Static IP
Is it possible to have static. IP Address instead of Dynamic IP for getting the IP Address whitelist
- How to use dart workspaces to deploy a f...
Hello, I'm developing a Flutter application and I would like to leverage dart pub workspaces to deploy a function with a dart runtime as advertised here : http...
- Appwrite Functions not executing with a ...
I have multiple functions running with a CRON Job however, they all stopped executing around 35 mins ago from this post. Project ID:6a4a03920012bede992d Region:...