Skip to content

Forms follow-up: fix update_form docstring, test cleanup, and submission ordering#48

Merged
oleksandr-nc merged 1 commit into
mainfrom
feature/p4-forms-followup-fixes
Apr 24, 2026
Merged

Forms follow-up: fix update_form docstring, test cleanup, and submission ordering#48
oleksandr-nc merged 1 commit into
mainfrom
feature/p4-forms-followup-fixes

Conversation

@oleksandr-nc
Copy link
Copy Markdown
Contributor

@oleksandr-nc oleksandr-nc commented Apr 24, 2026

Summary

Three small follow-up fixes to the Forms tools merged in #47. All found during a deep production-readiness audit; none caught by CI because the first is a docstring-only change and the other two are test-hygiene improvements that don't affect green CI.

Fixes

1. update_form docstring: filePathpath (real bug)

The Forms v3 API uses path (not filePath) as the keyValuePairs key to link a form to a submissions spreadsheet. I verified this against both:

  • Server source: apps-extra/forms/lib/Controller/ApiController.php:320 checks isset($keyValuePairs['path']).
  • Live API test:
    PATCH .../forms/{id} {"keyValuePairs": {"filePath": "/x", "fileFormat": "csv"}}
    → 500 "filePath is not a valid attribute"
    
    PATCH .../forms/{id} {"keyValuePairs": {"path": "/x", "fileFormat": "csv"}}
    → 200 OK, fileId assigned
    

An AI following the old docstring to link a form to a file would get a 500. Also clarified in the docstring that path and fileFormat must be sent together.

2. test_create_produces_form_with_id no longer leaks a form

The test called create_form (which produces a form with empty title) but never renamed it, so the cleanup filter (title.startswith("mcp-test-")) skipped it. Harmless in CI (fresh instance each run) but pollutes local-dev DBs. Now tags the form with a mcp-test-create-id title via update_form — placed before the assertions so cleanup catches the form even if an assertion fails mid-test.

3. test_delete_single_submission no longer assumes submission ordering

Previously picked listing[\"submissions\"][0][\"id\"], implicitly relying on OCS v3's return order. Now uses min(s[\"id\"] for s in listing[\"submissions\"]) (auto-increment IDs are monotonic → oldest submission deterministically). Also added an assertion that the target was actually removed, not just that the count dropped.

Test plan

  • ruff + pyright strict: clean
  • 104 unit tests pass
  • 34 Forms integration tests pass locally against live Nextcloud 5.3.0-dev.0 (151s)
  • test_server.py tool registry: 8/8 pass (no tool count change)
  • CI green on NC 32 + NC 33

Summary by CodeRabbit

  • Documentation
    • Updated update_form parameter documentation: path now specifies the destination folder for exported submission spreadsheets and must be set alongside fileFormat.

@coderabbitai
Copy link
Copy Markdown

coderabbitai Bot commented Apr 24, 2026

📝 Walkthrough

Walkthrough

The update_form tool's documentation was updated to clarify parameter naming and requirements: filePath was renamed to path, and the field is now explicitly described as requiring both fileFormat to link forms to exported submission spreadsheet locations. Integration tests were also modified to add form title updates and improve submission deletion verification logic.

Changes

Cohort / File(s) Summary
Forms Tool Documentation
src/nc_mcp_server/tools/forms.py
Updated key_value_pairs parameter documentation for update_form tool: renamed filePath field to path, clarified it specifies destination folder for exported submission spreadsheets, and noted that path must be provided alongside fileFormat to (re)link form to file.
Forms Integration Tests
tests/integration/test_forms.py
Added update_form call in test_create_produces_form_with_id to set form title after creation. Modified test_delete_single_submission to target minimum submission id (instead of first listed) and verify deletion via id-based assertion.

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~8 minutes

Possibly related PRs

Poem

🐰 A path clarified, a field renamed with care,
Tests grow stronger, deletion's done fair,
Update your forms with precision so true,
Documentation blooms—fresh and new! 🌱

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 20.00% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title directly summarizes the three main changes in the changeset: the update_form docstring fix, test cleanup, and submission ordering improvements.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch feature/p4-forms-followup-fixes

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

@oleksandr-nc oleksandr-nc marked this pull request as ready for review April 24, 2026 07:39
Copy link
Copy Markdown

@coderabbitai coderabbitai Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🧹 Nitpick comments (1)
src/nc_mcp_server/tools/forms.py (1)

205-207: Docstring fix looks correct; consider a tiny polish for fileFormat.

The filePathpath correction aligns with the Forms v3 keyValuePairs schema and matches the observed server behavior cited in the PR description, and the "must be sent together with fileFormat" note is a useful gotcha to surface to callers. No runtime behavior changes here.

Optional nit: fileFormat is listed without any description while path has one, which reads slightly asymmetrically. You could tighten it to something like:

Optional docstring polish
-                permitAllUsers/showToAllUsers), fileFormat, path (destination
-                folder for the generated submissions spreadsheet — must be sent
-                together with fileFormat to (re)link the form to a file).
+                permitAllUsers/showToAllUsers), fileFormat ("csv"/"xlsx"/"ods")
+                and path (destination folder for the generated submissions
+                spreadsheet) — these two must be sent together to (re)link the
+                form to an exported submissions file.
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@src/nc_mcp_server/tools/forms.py` around lines 205 - 207, The docstring
currently mentions fileFormat and path (keyValuePairs for Forms v3) but leaves
fileFormat undocumented; add a concise description for fileFormat next to the
existing path note in the same docstring so both entries are symmetric—e.g.,
clarify that fileFormat is the format/type of the linked file (CSV, XLSX, etc.)
and that it must be sent together with path when (re)linking the form; update
the docstring where fileFormat and path are listed to keep wording parallel and
reference the Forms v3 keyValuePairs behavior.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Nitpick comments:
In `@src/nc_mcp_server/tools/forms.py`:
- Around line 205-207: The docstring currently mentions fileFormat and path
(keyValuePairs for Forms v3) but leaves fileFormat undocumented; add a concise
description for fileFormat next to the existing path note in the same docstring
so both entries are symmetric—e.g., clarify that fileFormat is the format/type
of the linked file (CSV, XLSX, etc.) and that it must be sent together with path
when (re)linking the form; update the docstring where fileFormat and path are
listed to keep wording parallel and reference the Forms v3 keyValuePairs
behavior.

ℹ️ Review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: 1d739a60-d357-4f22-a1af-15c48dee4d99

📥 Commits

Reviewing files that changed from the base of the PR and between cf5a339 and a491240.

📒 Files selected for processing (2)
  • src/nc_mcp_server/tools/forms.py
  • tests/integration/test_forms.py

@oleksandr-nc oleksandr-nc merged commit c9f0e61 into main Apr 24, 2026
12 checks passed
@oleksandr-nc oleksandr-nc deleted the feature/p4-forms-followup-fixes branch April 24, 2026 07:58
@oleksandr-nc oleksandr-nc mentioned this pull request Apr 24, 2026
3 tasks
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.

1 participant