[Bug]: Context Agent crashes with TypeError (tool_status NoneType) due to 400 Bad Request on config init
メンテナーはふだん 1 日以内に返信
まだ誰も着手していません。
評価
- 難易度
- 4/5
- 見積もり時間
- 3〜5日
- 初心者へのやさしさ
- 45/100
調査の方向性
/ex_app/lib/main.py の enabled_handler から始め、次に /ex_app/lib/tools.py の get_tools と、traceback に示されている失敗する AppAPI config POST を調べます。デプロイと設定の切り替えを再現し、tool_status が永続化または返却されない理由を追跡し、デフォルト JSON が再起動後も維持され、タスクで NoneType TypeError が発生しなくなることを確認します。
索引モデルが issue の本文から書いたものです。
説明
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.
- 主要言語
- PHP
- スター
- 202
- フォーク
- 30
- 平均マージ
- 3日 20時間
- マージ済み PR(30日)
- 24
環境構築
- Dockerfile・Docker Compose ファイルなし
- プルリクエストのテンプレートなし
- コントリビューションガイドを読む
はじめの一歩
- issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
- 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
- リポジトリをフォークし、ブランチを切って変更します。
- issue 番号を参照したプルリクエストを送ります。
nextcloud/app_api のほかの issue
-
bug docker
難易度 2/5 1〜3時間 初心者へのやさしさ 72/100
メンテナーはふだん 1 日以内に返信
-
難易度 2/5 1〜3時間 初心者へのやさしさ 85/100
メンテナーはふだん 1 日以内に返信
-
deploy discussion
難易度 5/5 1週間以上 初心者へのやさしさ 20/100
nextcloud/app_api#1236 · リアクション 1 件 ·
メンテナーはふだん 1 日以内に返信
-
deploy docker enhancement
難易度 4/5 3〜5日 初心者へのやさしさ 48/100
メンテナーはふだん 1 日以内に返信
-
bug deploy docker
難易度 4/5 3〜5日 初心者へのやさしさ 42/100
メンテナーはふだん 1 日以内に返信
nextcloud/app_api の issue をすべて見る
似ている issue
-
難易度 2/5 1〜3時間 初心者へのやさしさ 77/100
Adyen/adyen-magento2#3453 ·
メンテナーはふだん 8 日以内に返信
-
component/media domain/discovery
難易度 2/5 1〜3時間 初心者へのやさしさ 82/100
メンテナーはふだん 1 日以内に返信
-
難易度 2/5 1〜3時間 初心者へのやさしさ 82/100
-
難易度 2/5 1〜3時間 初心者へのやさしさ 79/100
メンテナーはふだん 1 日以内に返信
-
enhancement priority: low
難易度 2/5 1〜3時間 初心者へのやさしさ 82/100
magicsunday/webtrees-statistics#664 ·
メンテナーはふだん 1 日以内に返信