Skip to content

fix(clickup-app): retrieve folder-contained lists in get_all_lists (#13808) - #13809

Closed
Aj2280 wants to merge 2 commits into
BasedHardware:mainfrom
Aj2280:fix/clickup-folder-lists
Closed

Aj2280 wants to merge 2 commits into
BasedHardware:mainfrom
Aj2280:fix/clickup-folder-lists

Conversation

@Aj2280

@Aj2280 Aj2280 commented Sep 14, 2026 •

Copy link
Copy Markdown
Contributor

Summary

get_all_lists() in plugins/omi-clickup-app/clickup_client.py only queried GET /space/{space_id}/list, which in ClickUp API v2 exclusively returns folderless lists. Any lists created or organized inside folders were completely invisible to list fetching, preventing users from selecting them in the settings UI or routing tasks to them.

This change:

  1. Adds get_folders() to query GET /space/{space_id}/folder and retrieve all folders in a space.
  2. Adds get_folder_lists() to retrieve lists for a specific folder if not already embedded.
  3. Updates get_all_lists() to aggregate both folderless lists and folder-contained lists, properly formatted with folder_name / list_name for clear disambiguation.
  4. Adds hermetic unit test coverage in plugins/omi-clickup-app/test_clickup_client.py and registers clickup-app-client-tests in .github/checks-manifest.yaml.

Test plan

  • Unit tests in plugins/omi-clickup-app/test_clickup_client.py: 6 passed in 0.001s, asserting folderless and folder lists are both retrieved, and failure modes fail-closed to [].
  • Check manifest contract and preflight pass.

Failure-Class: none

Closes #13808

Review in cubic

@cubic-dev-ai cubic-dev-ai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

4 issues found across 3 files

Confidence score: 2/5

  • plugins/omi-clickup-app/clickup_client.py can turn HTML in a ClickUp folder name into stored XSS when the settings template renders lst['name'] unescaped, creating a direct security risk — escape folder/list names at the HTML rendering boundary before merging.
  • plugins/omi-clickup-app/clickup_client.py treats folder-fetch failures as an empty collection, so /refresh-lists can report success while silently dropping existing lists; propagate the failure or preserve the existing list set.
  • plugins/omi-clickup-app/test_clickup_client.py does not cover the fallback path that calls get_folder_lists when a folder response lacks lists, leaving the new behavior insufficiently verified — add a focused test for that branch.
  • plugins/omi-clickup-app/test_clickup_client.py leaves global requests and dotenv stubs installed, which can contaminate other tests in the same process; scope or clean up the module stubs.

You’re at about 90% of the monthly reviewed-line limit. You may want to disable incremental reviews to conserve quota. Reviews will continue until that limit is exceeded. If you need help avoiding interruptions, please contact [email protected].

Prompt for AI agents (unresolved issues)

Check if these issues are valid — if so, understand the root cause of each and fix them. If appropriate, use sub-agents to investigate and fix each issue separately.


<file name="plugins/omi-clickup-app/clickup_client.py">

<violation number="1" location="plugins/omi-clickup-app/clickup_client.py:242">
P2: When the folder request fails, this call treats the failure as an empty folder collection and returns a successful folderless subset. Propagate folder-fetch failure or preserve the existing list set so `/refresh-lists` does not hide all folder lists after a transient ClickUp error.</violation>

<violation number="2" location="plugins/omi-clickup-app/clickup_client.py:254">
P1: When a ClickUp folder name contains HTML, this new display name enables stored XSS in the settings page because the template renders `lst['name']` unescaped. Escape folder/list names at the HTML rendering boundary before inserting them into the option element.</violation>
</file>

<file name="plugins/omi-clickup-app/test_clickup_client.py">

<violation number="1" location="plugins/omi-clickup-app/test_clickup_client.py:16">
P3: The top-of-file stubbing replaces the global `requests` and `dotenv` modules in `sys.modules` for the whole process and never removes them. That is fine for this standalone `python3 ... test_clickup_client.py` run, but if the file is ever collected with other tests in the same pytest session, every subsequent `import requests` / `import dotenv` in that process gets the stub. Restore both module entries after importing `clickup_client`, or make the stubs conditional on the actual import failing, so the shadowing cannot leak beyond this module.</violation>

<violation number="2" location="plugins/omi-clickup-app/test_clickup_client.py:115">
P2: The integration test only exercises the branch where ClickUp embeds `lists` inside the folder response; the other new code path (folder dict has no `lists` key → `get_folder_lists` called, result reformatted with `folder_name / list_name`) is never exercised from `get_all_lists`. Also, the fail-closed test asserts individual methods return [] on 500 but never asserts `get_all_lists` itself fails closed (e.g., when `get_folders` errors). Add a case where the folder response omits `lists` and mock `get_folder_lists`, asserting its list appears with the combined display name, plus a 500-path assertion on `get_all_lists`.</violation>
</file>

Reply with feedback, questions, or to request a fix.

Re-trigger cubic


for lst in folder_lists:
list_name = lst.get("name", "")
display_name = f"{folder_name} / {list_name}" if folder_name else list_name

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P1: When a ClickUp folder name contains HTML, this new display name enables stored XSS in the settings page because the template renders lst['name'] unescaped. Escape folder/list names at the HTML rendering boundary before inserting them into the option element.

Prompt for AI agents
Check if this issue is valid — if so, understand the root cause and fix it. At plugins/omi-clickup-app/clickup_client.py, line 254:

<comment>When a ClickUp folder name contains HTML, this new display name enables stored XSS in the settings page because the template renders `lst['name']` unescaped. Escape folder/list names at the HTML rendering boundary before inserting them into the option element.</comment>

<file context>
@@ -161,32 +161,108 @@ def get_lists(self, access_token: str, space_id: str) -> List[Dict]:
+
+                for lst in folder_lists:
+                    list_name = lst.get("name", "")
+                    display_name = f"{folder_name} / {list_name}" if folder_name else list_name
+                    all_lists.append({
+                        "id": lst.get("id"),
</file context>



# 2. Get lists organized within folders in the space
folders = self.get_folders(access_token, space_id)

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P2: When the folder request fails, this call treats the failure as an empty folder collection and returns a successful folderless subset. Propagate folder-fetch failure or preserve the existing list set so /refresh-lists does not hide all folder lists after a transient ClickUp error.

Prompt for AI agents
Check if this issue is valid — if so, understand the root cause and fix it. At plugins/omi-clickup-app/clickup_client.py, line 242:

<comment>When the folder request fails, this call treats the failure as an empty folder collection and returns a successful folderless subset. Propagate folder-fetch failure or preserve the existing list set so `/refresh-lists` does not hide all folder lists after a transient ClickUp error.</comment>

<file context>
@@ -161,32 +161,108 @@ def get_lists(self, access_token: str, space_id: str) -> List[Dict]:
-        
+
+            # 2. Get lists organized within folders in the space
+            folders = self.get_folders(access_token, space_id)
+            for folder in folders:
+                folder_id = folder.get("id")
</file context>

{
"id": "folder-1",
"name": "Current Sprint",
"lists": [{"id": "list-2", "name": "Active Tasks"}]

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P2: The integration test only exercises the branch where ClickUp embeds lists inside the folder response; the other new code path (folder dict has no lists key → get_folder_lists called, result reformatted with folder_name / list_name) is never exercised from get_all_lists. Also, the fail-closed test asserts individual methods return [] on 500 but never asserts get_all_lists itself fails closed (e.g., when get_folders errors). Add a case where the folder response omits lists and mock get_folder_lists, asserting its list appears with the combined display name, plus a 500-path assertion on get_all_lists.

Prompt for AI agents
Check if this issue is valid — if so, understand the root cause and fix it. At plugins/omi-clickup-app/test_clickup_client.py, line 115:

<comment>The integration test only exercises the branch where ClickUp embeds `lists` inside the folder response; the other new code path (folder dict has no `lists` key → `get_folder_lists` called, result reformatted with `folder_name / list_name`) is never exercised from `get_all_lists`. Also, the fail-closed test asserts individual methods return [] on 500 but never asserts `get_all_lists` itself fails closed (e.g., when `get_folders` errors). Add a case where the folder response omits `lists` and mock `get_folder_lists`, asserting its list appears with the combined display name, plus a 500-path assertion on `get_all_lists`.</comment>

<file context>
@@ -0,0 +1,148 @@
+            {
+                "id": "folder-1",
+                "name": "Current Sprint",
+                "lists": [{"id": "list-2", "name": "Active Tasks"}]
+            }
+        ]
</file context>

requests_stub = types.ModuleType("requests")
requests_stub.get = lambda *args, **kwargs: None
requests_stub.post = lambda *args, **kwargs: None
sys.modules["requests"] = requests_stub

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P3: The top-of-file stubbing replaces the global requests and dotenv modules in sys.modules for the whole process and never removes them. That is fine for this standalone python3 ... test_clickup_client.py run, but if the file is ever collected with other tests in the same pytest session, every subsequent import requests / import dotenv in that process gets the stub. Restore both module entries after importing clickup_client, or make the stubs conditional on the actual import failing, so the shadowing cannot leak beyond this module.

Prompt for AI agents
Check if this issue is valid — if so, understand the root cause and fix it. At plugins/omi-clickup-app/test_clickup_client.py, line 16:

<comment>The top-of-file stubbing replaces the global `requests` and `dotenv` modules in `sys.modules` for the whole process and never removes them. That is fine for this standalone `python3 ... test_clickup_client.py` run, but if the file is ever collected with other tests in the same pytest session, every subsequent `import requests` / `import dotenv` in that process gets the stub. Restore both module entries after importing `clickup_client`, or make the stubs conditional on the actual import failing, so the shadowing cannot leak beyond this module.</comment>

<file context>
@@ -0,0 +1,148 @@
+    requests_stub = types.ModuleType("requests")
+    requests_stub.get = lambda *args, **kwargs: None
+    requests_stub.post = lambda *args, **kwargs: None
+    sys.modules["requests"] = requests_stub
+
+import os
</file context>

@Git-on-my-level

Copy link
Copy Markdown
Member

Verified end to end against the ClickUp API v2 docs and by running the new suite locally (6/6 pass, fully hermetic -- all HTTP mocked, no network). The core diagnosis behind #13808 is correct: GET /space/{id}/list returns folderless lists only, and GET /space/{id}/folder / GET /folder/{id}/list are the right endpoints for folder-contained ones.

Per file:

  • plugins/omi-clickup-app/clickup_client.py -- get_folders() and get_folder_lists() match the documented endpoints and the file's existing fail-closed-to-[] error convention. get_all_lists() aggregates folderless + folder lists and tags folder_id/folder_name; task routing stays intact since create_task only consumes id. Cosmetic nit: a folder named the same as its contained list renders as "X / X".
  • plugins/omi-clickup-app/test_clickup_client.py -- good hermetic coverage of the happy paths and per-method 500 fail-closed behavior. Two gaps: (1) the fallback branch in get_all_lists (folder.get("lists") is None -> get_folder_lists()) is never exercised end-to-end; a test would also pin the formatting contract for raw fallback dicts. (2) No assertion of what get_all_lists itself does when get_folders() errors. The process-global requests/dotenv stubs are harmless in the manifest's standalone invocation.
  • .github/checks-manifest.yaml -- clickup-app-client-tests entry mirrors the neighboring omi-github-app pattern (same triggers/lanes, direct python3 invocation); preflight passes.

On the injection point raised earlier in this thread: confirmed the sink. The settings page (main.py, unchanged by this PR) interpolates lst['name'] into <option> HTML unescaped, and ClickUp folder names are workspace-controlled text, so the new folder / list display names widen that pre-existing surface to folder names. The strict fix belongs at the HTML rendering boundary in main.py (escaping list, space, and folder names together) -- happy to see it as a follow-up, or folded in here if preferred.

The folder-fetch failure mode (empty folder set, keep folderless lists) matches how get_spaces/get_lists already degrade in this file, so it is consistent with the existing convention rather than a new regression; a pinning test would make the intent explicit.

Test-plan nit: the checklist says "6 passed in 0.001s"; locally it is 6 tests in ~0.002s -- just keep that line updated on re-runs.

Overall this is a correct, focused fix with the right tests registered in the manifest. Leaving the HTML-escaping boundary decision for maintainer sign-off since it is a security-flagged path; the rest looks in good shape.


by AI on behalf of David — if you need David’s attention urgently, please @Git-on-my-level and escalate with need human response.

@Git-on-my-level Git-on-my-level added python needs-maintainer-review Needs a human maintainer to sign off before merge labels Sep 14, 2026
…adation tests

- HTML-escape list id, display_name, and workspace name in settings page
- Add test asserting folder list fallback fetching when lists are not embedded
- Add test asserting graceful degradation to folderless lists on folder fetch error

Failure-Class: none
@Aj2280

Aj2280 commented Sep 14, 2026

Copy link
Copy Markdown
Contributor Author

Thanks for the thorough review and feedback @Git-on-my-level!

  • Added HTML escaping (html.escape) for list IDs, display names, and workspace names in main.py settings options.
  • Added unit tests asserting fallback folder-list fetching when lists is not embedded in the folder response, and asserting graceful degradation to folderless lists when folder fetching returns empty.
    All 8 unit tests pass in 0.002s and preflight is green in 5bd1d0d. Ready for maintainer merge sign-off.

@Git-on-my-level

Copy link
Copy Markdown
Member

Follow-up review on 5bd1d0d — verified the updates since the earlier automated pass:

  • plugins/omi-clickup-app/main.py — the settings page now escapes list ids, display names, and the workspace name at the option/<span> render sites (html.escape(..., quote=True) for the attribute value, plain escape for text). This closes the stored-XSS path for folder/list names reaching the picker that the earlier review flagged.
  • plugins/omi-clickup-app/test_clickup_client.py — both requested coverage gaps are now filled: test_get_all_lists_fetches_folder_lists_fallback_when_not_embedded pins the folder.get("lists") is None -> get_folder_lists() fallback (including assert_called_once_with and the "Milestone 1 / Tasks" formatting contract), and test_get_all_lists_degrades_gracefully_on_folder_fetch_failure covers folder-fetch failure degrading to folderless lists. I ran the suite locally: 8/8 pass, fully hermetic (requests/dotenv stubbed, every HTTP call mocked, no network).
  • plugins/omi-clickup-app/clickup_client.py — the aggregation is sound and unchanged since the last pass: get_all_lists merges folderless + folder lists, tags folder_id/folder_name, and create_task only consumes id, so task routing is unaffected. Non-method changes in the file are trailing-whitespace cleanup only. Minor cosmetic nit remains: a folder whose name equals its contained list renders as X / X.
  • .github/checks-manifest.yaml — the new clickup-app-client-tests entry mirrors the neighboring omi-github-app pattern (same triggers including the manifest itself, both local and ci lanes, direct python3 invocation); preflight is green.

One residual finding, pre-existing on main rather than introduced here: the OAuth callback success page in main.py (~line 596) still interpolates {team_name} unescaped inside <strong> (and {uid} into the continue-href). Since this PR already imports html and fixes the sibling sites, extending the same escaping there would be a natural small follow-up — happy for it to land here or as a trivial follow-up commit.

Core diagnosis confirmed against ClickUp API v2 behavior (GET /space/{id}/list returns folderless lists only), fix is correct, well tested, and checks are green. Human maintainer merge sign-off still pending (needs-maintainer-review retained) — that sign-off should also decide whether the escaping sweep extends to the remaining pre-existing render site.


by AI on behalf of David — if you need David’s attention urgently, please @Git-on-my-level and escalate with need human response.

@Git-on-my-level Git-on-my-level added the positive-signal Automation verified a genuine fix/quality contribution label Sep 15, 2026
@aryanorastar

Copy link
Copy Markdown
Collaborator

Keeping this open on 5bd1d0d60791.

unique clickup HTML escape in main.py vs #13288 folder-lists; extra production so not CLOSE; DIRTY.

I am not approving or merging this SHA.

@aryanorastar

Copy link
Copy Markdown
Collaborator

Closing because this is already on main (ClickUp folder lists are already walked). The keep is #13844. This head does not add a unique production file.

@github-actions

Copy link
Copy Markdown
Contributor

Hey @Aj2280 👋

Thank you so much for taking the time to contribute to Omi! We truly appreciate you putting in the effort to submit this pull request.

After careful review, we've decided not to merge this particular PR. Please don't take this personally — we genuinely try to merge as many contributions as possible, but sometimes we have to make tough calls based on:

  • Project standards — Ensuring consistency across the codebase
  • User needs — Making sure changes align with what our users need
  • Code best practices — Maintaining code quality and maintainability
  • Project direction — Keeping aligned with our product principles and locked invariants

Before your next PR, please skim:

  • PRODUCT.md — product north star
  • Product invariants — locked rules (shared chat, memory tiers, agent control plane, integrations, brand)

If this was declined for direction or taste, maintainers should cite an invariant ID or open a proposed one — ask if that citation is missing.

Your contribution is still valuable to us, and we'd love to see you contribute again in the future! If you'd like feedback on how to improve this PR or want to discuss alternative approaches, please don't hesitate to reach out.

Thank you for being part of the Omi community!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

needs-maintainer-review Needs a human maintainer to sign off before merge positive-signal Automation verified a genuine fix/quality contribution python

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Bounty proposal] fix(clickup-app): folder-contained lists invisible in get_all_lists

3 participants