[Bug]: Context Agent crashes with TypeError (tool_status NoneType) due to 400 Bad Request on config init
Les mainteneurs répondent en général sous 1 jour
Personne n'a encore pris cette issue.
Évaluation
- Difficulté
- 4/5
- Temps estimé
- 3-5 jours
- Accessibilité débutants
- 45/100
Piste de recherche
Commencez dans /ex_app/lib/main.py au niveau de enabled_handler, puis examinez /ex_app/lib/tools.py au niveau de get_tools ainsi que le AppAPI config POST en échec affiché dans la trace. Reproduisez le déploiement et le basculement de configuration, suivez la raison pour laquelle tool_status n’est pas persisté ou renvoyé, et vérifiez que le JSON par défaut survit au redémarrage et que les tâches ne déclenchent plus de NoneType TypeError.
Rédigé par le modèle d'indexation à partir du texte de l'issue.
Description
Description
Upon freshly deploying the Context Agent, it fails to initialize its default tool configuration. Any attempt to interact with the agent results in a crash because nc.appconfig_ex.get_value('tool_status') returns None.
Under the hood, it appears the enabled_handler is attempting to POST its default preferences to the AppAPI config endpoint, but the Nextcloud server rejects it with a 400 Bad Request. Because the save is rejected, the JSON is never written, causing json.loads() to throw a TypeError on every subsequent task.
Environment
- Nextcloud Version: NC 32.0.8 AIO 12.9.2
- AppAPI Version: Latest
- Context Agent Version: Latest
- LLM Backend: Ollama
Steps to Reproduce
- Deploy the Context Agent via AppAPI.
- Send a message to the Nextcloud Assistant assigned to the Context Agent provider.
- Observe the "Error generating a response" banner in the UI.
- Attempt to go to Administration Settings -> Context Agent and toggle a permission (e.g., Calendar) to force a save. The UI fails to write the config.
Expected Behavior
The Agent should successfully write its default tool_status JSON via the AppAPI upon deployment, and correctly read those permissions to handle tool-calling tasks.
Actual Behavior & Logs
The container fails to set the configuration during the enabled callback, throwing a 400 error:
2026-04-20 14:54:13,252 - context_agent - INFO - enabled=True
2026-04-20 14:54:13,612 - context_agent - WARNING - App enabled: context_agent
INFO: - "PUT /enabled?enabled=1 HTTP/1.1" 500 Internal Server Error
# ... [Traceback skipped for brevity] ...
File "/ex_app/lib/main.py", line 126, in enabled_handler
await nc.appconfig_ex.set_value('tool_status', json.dumps(pref_settings))
File "/root/.cache/pypoetry/virtualenvs/context-agent-il7asoJj-py3.11/lib/python3.11/site-packages/nc_py_api/_preferences_ex.py", line 135, in set_value
await self._session.ocs("POST", f"{self._session.ae_url}/{self._url_suffix}", json=params)
File "/root/.cache/pypoetry/virtualenvs/context-agent-il7asoJj-py3.11/lib/python3.11/site-packages/nc_py_api/_session.py", line 371, in ocs
raise NextcloudException(
nc_py_api._exceptions.NextcloudException: [400] Error setting app config value <request: POST /ocs/v1.php/apps/app_api/api/v1/ex-app/config>
When a task is received, it instantly crashes trying to read the blank config:
2026-04-20 14:55:43,874 - context_agent - INFO - {'input': 'Hi there, would you tell me my evening programs from my calendar for today?', 'confirmation': 0, 'conversation_token': '<skipped>', 'memories': None}
2026-04-20 14:55:44,235 - context_agent - ERROR - Error: Traceback (most recent call last):
File "/ex_app/lib/main.py", line 180, in handle_task
output = await react(task, nextcloud)
File "/ex_app/lib/agent.py", line 97, in react
safe_tools, dangerous_tools = await get_tools(nc)
File "/ex_app/lib/tools.py", line 21, in get_tools
is_activated = json.loads(await nc.appconfig_ex.get_value('tool_status'))
File "/usr/local/lib/python3.11/json/__init__.py", line 339, in loads
raise TypeError(f'the JSON object must be str, bytes or bytearray, '
TypeError: the JSON object must be str, bytes or bytearray, not NoneType
Troubleshooting Attempted
I attempted to bypass the 400 API error by hardcoding the configuration directly into Nextcloud via OCC:
docker exec --user www-data nextcloud-aio-nextcloud php occ config:app:set context_agent tool_status --value='{"calendar":true}'
This successfully saved to the fast cache, but the nc_py_api bridge still fetched NoneType upon container restart, indicating a disconnect between standard occ configs and appconfig_ex ExApp storage.
- Langage dominant
- PHP
- Étoiles
- 202
- Forks
- 30
- Merge moyen
- 3 j 20 h
- PR mergées (30 j)
- 24
Préparer son environnement
- Aucun Dockerfile ni fichier Docker Compose
- Aucun modèle de pull request
- Lire le guide de contribution
Par où commencer
- Lisez l'issue en entier, puis le guide de contribution du projet.
- Signalez en commentaire que vous la prenez — cela évite que deux personnes fassent le même travail.
- Forkez le dépôt et travaillez sur une branche.
- Ouvrez une pull request qui référence le numéro de l'issue.
Autres issues de nextcloud/app_api
-
bug docker
Difficulté 2/5 1-3 heures Accessibilité débutants 72/100
Les mainteneurs répondent en général sous 1 jour
-
Daemon delete dialog: "Remove all ExApps" checkbox and `removeExApps` parameter have no effectOuverte
Difficulté 2/5 1-3 heures Accessibilité débutants 85/100
Les mainteneurs répondent en général sous 1 jour
-
Meta ex-app updates issueOuvertedeploy discussion
Difficulté 5/5 Plus d'une semaine Accessibilité débutants 20/100
nextcloud/app_api#1236 · 1 réaction ·
Les mainteneurs répondent en général sous 1 jour
-
deploy docker enhancement
Difficulté 4/5 3-5 jours Accessibilité débutants 48/100
Les mainteneurs répondent en général sous 1 jour
-
bug deploy docker
Difficulté 4/5 3-5 jours Accessibilité débutants 42/100
Les mainteneurs répondent en général sous 1 jour
Toutes les issues de nextcloud/app_api
Issues similaires
-
Difficulté 2/5 1-3 heures Accessibilité débutants 77/100
Adyen/adyen-magento2#3453 ·
Les mainteneurs répondent en général sous 8 jours
-
component/media domain/discovery
Difficulté 2/5 1-3 heures Accessibilité débutants 82/100
Les mainteneurs répondent en général sous 1 jour
-
Difficulté 2/5 1-3 heures Accessibilité débutants 82/100
-
Difficulté 2/5 1-3 heures Accessibilité débutants 79/100
Les mainteneurs répondent en général sous 1 jour
-
enhancement priority: low
Difficulté 2/5 1-3 heures Accessibilité débutants 82/100
magicsunday/webtrees-statistics#664 ·
Les mainteneurs répondent en général sous 1 jour