Skip to content

[bug]: Error in nextcloud.log "token does not exist" when try to schedule a job type text2text #520

Description

@crlgnd

Describe the bug
Error in nextcloud.log "token does not exist" when try to schedule a job text2text

{"reqId":"Law2TcJ7hOSQMdCqCj4c","level":0,"time":"2025-02-13T21:10:11+00:00","remoteAddr":"192.168.1.60","user":"admin","app":"core","method":"POST","url":"/nextcloud/ocs/v1.php/taskprocessing/schedule?format=json","message":"Session token is invalid because it does not exist","userAgent":"ExApp/context_chat_backend/4.0.7 (httpx/0.28.1)","version":"30.0.5.1","exception":{"Exception":"OC\Authentication\Exceptions\InvalidTokenException","Message":"Token does not exist: token does not exist

To Reproduce
Steps to reproduce the behavior:

  1. Install AppApi
  2. Register Context_Chat_Backend
  3. Enable Context_Chat
  4. Enable Assistant
  5. Open Assistant on browser and ask something or execute occ context_chat:prompt admin "something"
  6. As soon as cron.php runs the error is printed

Expected behavior
I expect

Server logs (if applicable)

Details
{"reqId":"LgXhOz9lk8OdL3heH2H1","level":0,"time":"2025-02-13T11:00:15+00:00","remoteAddr":"192.168.1.60","user":"admin","app":"core","method":"POST","url":"/nextcloud/ocs/v1.php/taskprocessing/schedule?format=json","message":"Session token is invalid because it does not exist","userAgent":"ExApp/context_chat_backend/4.0.7 (httpx/0.28.1)","version":"30.0.5.1","exception":{"Exception":"OC\\Authentication\\Exceptions\\InvalidTokenException","Message":"Token does not exist: token does not exist","Code":0,"Trace":[{"file":"/var/www/html/nextcloud/lib/private/Authentication/Token/Manager.php","line":118,"function":"getToken","class":"OC\\Authentication\\Token\\PublicKeyTokenProvider","type":"->","args":["*** sensitive parameters replaced ***"]},{"file":"/var/www/html/nextcloud/lib/private/User/Session.php","line":748,"function":"getToken","class":"OC\\Authentication\\Token\\Manager","type":"->","args":["*** sensitive parameters replaced ***"]},{"file":"/var/www/html/nextcloud/lib/private/User/Session.php","line":209,"function":"validateToken","class":"OC\\User\\Session","type":"->","args":["*** sensitive parameters replaced ***"]},{"file":"/var/www/html/nextcloud/lib/private/User/Session.php","line":184,"function":"validateSession","class":"OC\\User\\Session","type":"->"},{"file":"/var/www/html/nextcloud/lib/private/legacy/OC_App.php","line":187,"function":"getUser","class":"OC\\User\\Session","type":"->"},{"file":"/var/www/html/nextcloud/lib/private/App/AppManager.php","line":193,"function":"getEnabledApps","class":"OC_App","type":"::"},{"file":"/var/www/html/nextcloud/lib/private/legacy/OC_App.php","line":85,"function":"loadApps","class":"OC\\App\\AppManager","type":"->"},{"file":"/var/www/html/nextcloud/lib/private/legacy/OC_User.php","line":106,"function":"loadApps","class":"OC_App","type":"::"},{"file":"/var/www/html/nextcloud/lib/base.php","line":729,"function":"setupBackends","class":"OC_User","type":"::"},{"file":"/var/www/html/nextcloud/lib/base.php","line":1134,"function":"init","class":"OC","type":"::"},{"file":"/var/www/html/nextcloud/ocs/v1.php","line":8,"args":["/var/www/html/nextcloud/lib/base.php"],"function":"require_once"}],"File":"/var/www/html/nextcloud/lib/private/Authentication/Token/PublicKeyTokenProvider.php","Line":165,"Previous":{"Exception":"OCP\\AppFramework\\Db\\DoesNotExistException","Message":"token does not exist","Code":0,"Trace":[{"file":"/var/www/html/nextcloud/lib/private/Authentication/Token/PublicKeyTokenProvider.php","line":157,"function":"getToken","class":"OC\\Authentication\\Token\\PublicKeyTokenMapper","type":"->","args":["*** sensitive parameters replaced ***"]},{"file":"/var/www/html/nextcloud/lib/private/Authentication/Token/Manager.php","line":118,"function":"getToken","class":"OC\\Authentication\\Token\\PublicKeyTokenProvider","type":"->","args":["*** sensitive parameters replaced ***"]},{"file":"/var/www/html/nextcloud/lib/private/User/Session.php","line":748,"function":"getToken","class":"OC\\Authentication\\Token\\Manager","type":"->","args":["*** sensitive parameters replaced ***"]},{"file":"/var/www/html/nextcloud/lib/private/User/Session.php","line":209,"function":"validateToken","class":"OC\\User\\Session","type":"->","args":["*** sensitive parameters replaced ***"]},{"file":"/var/www/html/nextcloud/lib/private/User/Session.php","line":184,"function":"validateSession","class":"OC\\User\\Session","type":"->"},{"file":"/var/www/html/nextcloud/lib/private/legacy/OC_App.php","line":187,"function":"getUser","class":"OC\\User\\Session","type":"->"},{"file":"/var/www/html/nextcloud/lib/private/App/AppManager.php","line":193,"function":"getEnabledApps","class":"OC_App","type":"::"},{"file":"/var/www/html/nextcloud/lib/private/legacy/OC_App.php","line":85,"function":"loadApps","class":"OC\\App\\AppManager","type":"->"},{"file":"/var/www/html/nextcloud/lib/private/legacy/OC_User.php","line":106,"function":"loadApps","class":"OC_App","type":"::"},{"file":"/var/www/html/nextcloud/lib/base.php","line":729,"function":"setupBackends","class":"OC_User","type":"::"},{"file":"/var/www/html/nextcloud/lib/base.php","line":1134,"function":"init","class":"OC","type":"::"},{"file":"/var/www/html/nextcloud/ocs/v1.php","line":8,"args":["/var/www/html/nextcloud/lib/base.php"],"function":"require_once"}],"File":"/var/www/html/nextcloud/lib/private/Authentication/Token/PublicKeyTokenMapper.php","Line":81},"message":"Session token is invalid because it does not exist","user":null,"exception":{},"CustomMessage":"Session token is invalid because it does not exist"}}

Context Chat Backend logs (if applicable, from the docker container)

Details
{"timestamp": "2025-02-14T19:57:56.492438+00:00", "level": "ERROR", "logger": "uvicorn.error", "message": "Exception in ASGI application\n", "filename": "h11_impl.py", "function": "run_asgi", "line": 408, "thread_name": "MainThread", "pid": 65, "exc_info": "Traceback (most recent call last):\n  File \"/usr/local/lib/python3.11/dist-packages/uvicorn/protocols/http/h11_impl.py\", line 403, in run_asgi\n    result = await app(  # type: ignore[func-returns-value]\n             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^\n  File \"/usr/local/lib/python3.11/dist-packages/uvicorn/middleware/proxy_headers.py\", line 60, in __call__\n    return await self.app(scope, receive, send)\n           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^\n  File \"/usr/local/lib/python3.11/dist-packages/fastapi/applications.py\", line 1054, in __call__\n    await super().__call__(scope, receive, send)\n  File \"/usr/local/lib/python3.11/dist-packages/starlette/applications.py\", line 112, in __call__\n    await self.middleware_stack(scope, receive, send)\n  File \"/usr/local/lib/python3.11/dist-packages/starlette/middleware/errors.py\", line 187, in __call__\n    raise exc\n  File \"/usr/local/lib/python3.11/dist-packages/starlette/middleware/errors.py\", line 165, in __call__\n    await self.app(scope, receive, _send)\n  File \"/app/context_chat_backend/ocs_utils.py\", line 73, in __call__\n    await self.app(scope, receive, send)\n  File \"/usr/local/lib/python3.11/dist-packages/starlette/middleware/exceptions.py\", line 62, in __call__\n    await wrap_app_handling_exceptions(self.app, conn)(scope, receive, send)\n  File \"/usr/local/lib/python3.11/dist-packages/starlette/_exception_handler.py\", line 53, in wrapped_app\n    raise exc\n  File \"/usr/local/lib/python3.11/dist-packages/starlette/_exception_handler.py\", line 42, in wrapped_app\n    await app(scope, receive, sender)\n  File \"/usr/local/lib/python3.11/dist-packages/starlette/routing.py\", line 715, in __call__\n    await self.middleware_stack(scope, receive, send)\n  File \"/usr/local/lib/python3.11/dist-packages/starlette/routing.py\", line 735, in app\n    await route.handle(scope, receive, send)\n  File \"/usr/local/lib/python3.11/dist-packages/starlette/routing.py\", line 288, in handle\n    await self.app(scope, receive, send)\n  File \"/usr/local/lib/python3.11/dist-packages/starlette/routing.py\", line 76, in app\n    await wrap_app_handling_exceptions(app, request)(scope, receive, send)\n  File \"/usr/local/lib/python3.11/dist-packages/starlette/_exception_handler.py\", line 53, in wrapped_app\n    raise exc\n  File \"/usr/local/lib/python3.11/dist-packages/starlette/_exception_handler.py\", line 42, in wrapped_app\n    await app(scope, receive, sender)\n  File \"/usr/local/lib/python3.11/dist-packages/starlette/routing.py\", line 73, in app\n    response = await f(request)\n               ^^^^^^^^^^^^^^^^\n  File \"/usr/local/lib/python3.11/dist-packages/fastapi/routing.py\", line 301, in app\n    raw_response = await run_endpoint_function(\n                   ^^^^^^^^^^^^^^^^^^^^^^^^^^^^\n  File \"/usr/local/lib/python3.11/dist-packages/fastapi/routing.py\", line 214, in run_endpoint_function\n    return await run_in_threadpool(dependant.call, **values)\n           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^\n  File \"/usr/local/lib/python3.11/dist-packages/starlette/concurrency.py\", line 37, in run_in_threadpool\n    return await anyio.to_thread.run_sync(func)\n           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^\n  File \"/usr/local/lib/python3.11/dist-packages/anyio/to_thread.py\", line 56, in run_sync\n    return await get_async_backend().run_sync_in_worker_thread(\n           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^\n  File \"/usr/local/lib/python3.11/dist-packages/anyio/_backends/_asyncio.py\", line 2461, in run_sync_in_worker_thread\n    return await future\n           ^^^^^^^^^^^^\n  File \"/usr/local/lib/python3.11/dist-packages/anyio/_backends/_asyncio.py\", line 962, in run\n    result = context.run(func, *args)\n             ^^^^^^^^^^^^^^^^^^^^^^^^\n  File \"/app/context_chat_backend/controller.py\", line 174, in wrapper\n    return func(*args, **kwargs)\n           ^^^^^^^^^^^^^^^^^^^^^\n  File \"/app/context_chat_backend/controller.py\", line 452, in _\n    return execute_query(query)\n           ^^^^^^^^^^^^^^^^^^^^\n  File \"/app/context_chat_backend/controller.py\", line 441, in execute_query\n    return exec_in_proc(target=target, args=args)\n           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^\n  File \"/app/context_chat_backend/utils.py\", line 97, in exec_in_proc\n    raise result['error']\nnc_py_api._exceptions.NextcloudException: [412] <request: POST /ocs/v1.php/taskprocessing/schedule>"}

Screenshots
If applicable, add screenshots to help explain your problem.

Setup Details (please complete the following information):

  • Nextcloud Version: 30.0.5 [eg. 28.0.1, master]
  • AppAPI Version: 4.0.5 [eg. 2.0.1]
  • Context Chat PHP Version: 4.0.6 [e.g. 1.0.0]
  • Context Chat Backend Version: 4.0.7 [e.g. 1.0.0]
  • Nextcloud deployment method: Apache bare-metal [eg. Apache bare-metal]
  • Context Chat Backend deployment method: AppAPI Daemon [eg. manual, one-click]

Additional context

Apps

Enabled:

  • activity: 3.0.0
  • app_api: 4.0.5
  • assistant: 2.3.0
  • bruteforcesettings: 3.0.0
  • circles: 30.0.0
  • cloud_federation_api: 1.13.0
  • comments: 1.20.1
  • contactsinteraction: 1.11.0
  • context_chat: 4.0.6
  • dashboard: 7.10.0
  • dav: 1.31.1
  • federatedfilesharing: 1.20.0
  • federation: 1.20.0
  • files: 2.2.0
  • files_downloadlimit: 3.0.0
  • files_pdfviewer: 3.0.0
  • files_reminders: 1.3.0
  • files_sharing: 1.22.0
  • files_trashbin: 1.20.1
  • files_versions: 1.23.0
  • firstrunwizard: 3.0.0
  • logreader: 3.0.0
  • lookup_server_connector: 1.18.0
  • nextcloud_announcements: 2.0.0
  • notifications: 3.0.0
  • oauth2: 1.18.1
  • password_policy: 2.0.0
  • photos: 3.0.2
  • privacy: 2.0.0
  • provisioning_api: 1.20.0
  • recommendations: 3.0.0
  • related_resources: 1.5.0
  • serverinfo: 2.0.0
  • settings: 1.13.0
  • sharebymail: 1.20.0
  • support: 2.0.0
  • survey_client: 2.0.0
  • systemtags: 1.20.0
  • text: 4.1.0
  • theming: 2.5.0
  • twofactor_backupcodes: 1.19.0
  • twofactor_totp: 12.0.0-dev
  • updatenotification: 1.20.0
  • user_status: 1.10.0
  • viewer: 3.0.0
  • weather_status: 1.10.0
  • webhook_listeners: 1.1.0-dev
  • workflowengine: 2.12.0
    Disabled:
  • admin_audit: 1.20.0
  • encryption: 2.18.0
  • files_external: 1.22.0
  • suspicious_login: 8.0.0
  • twofactor_nextcloud_notification: 4.0.0 (installed 4.0.0)
  • user_ldap: 1.21.0
    ExApps:
  • context_chat_backend (Context Chat Backend): 4.0.7 [enabled]
  • llm2 (Local large language model): 2.2.2 [enabled]
  • translate2 (Local Machine Translation): 2.0.3 [enabled]

Metadata

Metadata

Assignees

No one assigned

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions