codeant-ai-for-open-source[bot] commented on code in PR #41998:
URL: https://github.com/apache/superset/pull/41998#discussion_r3586045485


##########
superset/reports/api.py:
##########
@@ -683,13 +683,22 @@ def slack_channels(self, **kwargs: Any) -> Response:
             types = params.get("types", [])
             exact_match = params.get("exact_match", False)
             force = params.get("force", False)
+            page = params.get("page")
+            page_size = params.get("page_size")
             channels = get_channels_with_search(
                 search_string=search_string,
                 types=types,
                 exact_match=exact_match,
                 force=force,
             )
-            return self.response(200, result=channels)
+            # Paginate at the API layer so large workspaces (tens of thousands 
of
+            # channels) never ship the full list to the browser at once. The
+            # filtered set is served from the warm cache, so slicing is cheap.
+            count = len(channels)
+            if page is not None and page_size is not None:
+                start = page * page_size
+                channels = channels[start : start + page_size]
+            return self.response(200, count=count, result=channels)

Review Comment:
   **Suggestion:** The endpoint now returns an extra `count` field, but the 
documented response schema in this API method still describes only `result`. 
This creates an API contract mismatch for OpenAPI consumers and generated 
clients; update the documented response schema to include `count`. [api 
mismatch]
   
   <details>
   <summary><b>Severity Level:</b> Major ⚠️</summary>
   
   ```mdx
   - ⚠️ OpenAPI spec omits count field in response.
   - ⚠️ Generated clients lack total-count pagination metadata.
   - ⚠️ API consumers may misinterpret pagination capabilities.
   ```
   </details>
   <details>
   <summary><b>Steps of Reproduction ✅ </b></summary>
   
   ```mdx
   1. Inspect the `slack_channels` endpoint implementation in
   `superset/reports/api.py:628-639`; the method `slack_channels(self, 
**kwargs)` is
   documented with an OpenAPI-style docstring starting at 
`superset/reports/api.py:640`,
   under `get:` and `responses:`.
   
   2. Within that docstring at `superset/reports/api.py:653-655`, observe that 
the documented
   `200` response schema describes an `application/json` object with a single
   `properties.result` array of channel objects (`id`, `name`) and no `count` 
property
   mentioned.
   
   3. Examine the implementation below the docstring at 
`superset/reports/api.py:641-662` (PR
   hunk lines `681-701`); after computing `count = len(channels)` and 
optionally slicing, the
   method returns `return self.response(200, count=count, result=channels)` at 
PR line `701`,
   meaning the actual runtime JSON object contains both `result` and `count`.
   
   4. Confirm the mismatch in the published OpenAPI spec by opening
   `docs/static/resources/openapi.json` around lines `27880-27955`; the
   `/api/v1/report/slack_channels/` path’s `200` response schema (real line 
~27887) defines
   an object with a `result` array but no `count` property, so 
OpenAPI-generated clients and
   documentation describe a response without `count` even though the server 
always returns it
   as verified by 
`tests/unit_tests/reports/api_test.py::test_slack_channels_success` at
   lines `26-39`, which asserts `data["count"] == 1`.
   ```
   </details>
   
   [![Fix in 
Cursor](https://new-codeant-butcket.s3.us-west-1.amazonaws.com/badges/fix-in-cursor-flat.svg)](https://app.codeant.ai/fix-in-ide?tool=cursor&prompt_id=61ab8c10368149f19e7bd3fd3f7da74c&service=github&base_url=https%3A%2F%2Fgithub.com&org=apache&repo=apache%2Fsuperset)
 [![Fix in VSCode 
Claude](https://new-codeant-butcket.s3.us-west-1.amazonaws.com/badges/fix-in-vscode-claude-flat.svg)](https://app.codeant.ai/fix-in-ide?tool=vscode-claude&prompt_id=61ab8c10368149f19e7bd3fd3f7da74c&service=github&base_url=https%3A%2F%2Fgithub.com&org=apache&repo=apache%2Fsuperset)
   
   *(Use Cmd/Ctrl + Click for best experience)*
   <details>
   <summary><b>Prompt for AI Agent 🤖 </b></summary>
   
   ```mdx
   This is a comment left during a code review.
   
   **Path:** superset/reports/api.py
   **Line:** 701:701
   **Comment:**
        *Api Mismatch: The endpoint now returns an extra `count` field, but the 
documented response schema in this API method still describes only `result`. 
This creates an API contract mismatch for OpenAPI consumers and generated 
clients; update the documented response schema to include `count`.
   
   Validate the correctness of the flagged issue. If correct, How can I resolve 
this? If you propose a fix, implement it and please make it concise.
   Once fix is implemented, also check other comments on the same PR, and ask 
user if the user wants to fix the rest of the comments as well. if said yes, 
then fetch all the comments validate the correctness and implement a minimal fix
   ```
   </details>
   <a 
href='https://app.codeant.ai/feedback?pr_url=https%3A%2F%2Fgithub.com%2Fapache%2Fsuperset%2Fpull%2F41998&comment_hash=6663abf019d47f1c7becc8b22c65ca8b8d730b1ca55e00b1acbd19f4d50e3306&reaction=like'>👍</a>
 | <a 
href='https://app.codeant.ai/feedback?pr_url=https%3A%2F%2Fgithub.com%2Fapache%2Fsuperset%2Fpull%2F41998&comment_hash=6663abf019d47f1c7becc8b22c65ca8b8d730b1ca55e00b1acbd19f4d50e3306&reaction=dislike'>👎</a>



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to