Skip to content

Extract absolute_url from the app_api OCS response in download links - #287

Merged
marcelklehr merged 1 commit into
mainfrom
fix/doc-gen-absolute-url
Oct 22, 2026
Merged

marcelklehr merged 1 commit into
mainfrom
fix/doc-gen-absolute-url

Conversation

@WSHAPER

@WSHAPER WSHAPER commented Oct 22, 2026

Copy link
Copy Markdown
Contributor

The app_api OCS endpoint /ocs/v2.php/apps/app_api/api/v1/info/nextcloud_url/absolute answers with a dict ({"absolute_url": ...}). generate_document and generate_image f-stringed the whole response into their download links, so every link came out as {'absolute_url': 'https://...'}/104/output-file/.../download. This extracts absolute_url after the call in both tools.

Steps to reproduce

  1. ask the assistant to generate a document via the generate_document tool
  2. the tool fetches the instance URL from the endpoint above, which returns a dict, and f-strings it whole into the download link at both return sites (slides and the default file path), with no absolute_url extraction (ex_app/lib/all_tools/doc_gen.py)
  3. the chat model transcribes the mangled URL with a stray brace
  4. generate_image builds its link the same way (ex_app/lib/all_tools/image_gen.py)

Expected behaviour

every generate_document and generate_image link resolves; chat links fetch 200 consistently

Actual behaviour

links are mangled and 404 roughly two of three times in live testing

Fix

Extract absolute_url from the OCS response right after the call, in ex_app/lib/all_tools/doc_gen.py and ex_app/lib/all_tools/image_gen.py.

Testing

tests/test_doc_gen_links.py runs both tools against a hermetic fake whose nextcloud_url endpoint returns the dict shape the real controller returns (this is how the bug escaped: a fake answering with a bare string cannot see it). It covers both generate_document return sites (default file output and slides output) and the generate_image link, and asserts the links contain the bare URL plus the task path, with no dict-repr artifacts and no stray braces.

Cross-references

No existing issue or PR found for this defect (searched this repo's issues and PRs, 2026-10-22).


Assisted by opencode with zai/glm-5.3, reviewed by WSHAPER

…nload links

The nextcloud_url/absolute endpoint answers with {absolute_url: ...}, but
doc_gen.py and image_gen.py f-stringed the whole dict into the download URL,
producing links like {'absolute_url': '.../task'}/104/output-file/.../download.
The chat model transcribes those with varying success (observed live: stray
'}' or %7D, 404s roughly two of three times). Extract absolute_url after the
call in both files, and cover the link construction with tests whose fake
mirrors the real endpoint's dict shape.

Signed-off-by: WSHAPER <42714629+WSHAPER@users.noreply.github.com>

Assisted-by: opencode (zai/glm-5.3)
@marcelklehr
marcelklehr merged commit 4f24b64 into main Oct 22, 2026
7 checks passed
@marcelklehr
marcelklehr deleted the fix/doc-gen-absolute-url branch October 22, 2026 12:55
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants