Skip to content

📝(docs) fix resource server code snippet - #2536

Open
jmaupetit wants to merge 1 commit into
mainfrom
fix-resource-server-doc
Open

📝(docs) fix resource server code snippet#2536
jmaupetit wants to merge 1 commit into
mainfrom
fix-resource-server-doc

Conversation

@jmaupetit

Copy link
Copy Markdown
Contributor

Proposal

One needs to be authenticated while requesting the external API.

@jmaupetit jmaupetit self-assigned this Jul 23, 2026
@jmaupetit
jmaupetit requested a review from virgile-dev July 23, 2026 08:09
@jmaupetit jmaupetit added the documentation Improvements or additions to documentation label Jul 23, 2026
@coderabbitai

coderabbitai Bot commented Jul 23, 2026

Copy link
Copy Markdown

Review Change Stack

Walkthrough

The resource server documentation normalizes the EXTERNAL_API action list formatting. The “Create a document” requests.post(...) example now includes an Authorization: Bearer {access_token} header.

Estimated code review effort: 1 (Trivial) | ~2 minutes

Suggested reviewers: qbey

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Title check ✅ Passed The title clearly identifies the documentation code snippet fix described in the changeset.
Description check ✅ Passed The description explains that authentication is required for external API requests, which matches the documentation change.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
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.
✨ Finishing Touches 💡 1
🛠️ Fix failing CI checks 💡
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch fix-resource-server-doc

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.

@coderabbitai coderabbitai 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.

Actionable comments posted: 1

🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In `@documentation/resource_server.md`:
- Line 90: Update the multipart upload request in the documentation example to
remove the explicit Content-Type header while preserving the Authorization
Bearer header, allowing requests to generate the correct multipart/form-data
boundary automatically.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Repository UI

Review profile: ASSERTIVE

Plan: Pro Plus

Run ID: 9c2da300-630c-4f62-9dbb-4fc228bc20e0

📥 Commits

Reviewing files that changed from the base of the PR and between 9c3bc8a and 203d9c6.

📒 Files selected for processing (1)
  • documentation/resource_server.md

Comment thread documentation/resource_server.md Outdated
@virgile-dev
virgile-dev requested review from lunika and qbey and removed request for virgile-dev July 23, 2026 08:20
@jmaupetit
jmaupetit force-pushed the fix-resource-server-doc branch from 203d9c6 to 5bee213 Compare July 27, 2026 15:14

@lunika lunika left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Thanks !

One needs to be authenticated while requesting the external API.
@jmaupetit
jmaupetit force-pushed the fix-resource-server-doc branch from 5bee213 to 1fd0ea7 Compare August 5, 2026 08:36
@coderabbitai

coderabbitai Bot commented Aug 5, 2026

Copy link
Copy Markdown

Note

GitHub couldn't provide a complete incremental comparison for this pull request, so CodeRabbit is performing a full review instead. This review may take a little longer.

@coderabbitai coderabbitai 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.

Actionable comments posted: 1

🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In `@documentation/resource_server.md`:
- Line 90: Update the multipart upload example in the documentation to use
Requests’ files parameter with files={"file": file}, and remove the unsupported
format="multipart" argument while preserving the Authorization header.
🪄 Autofix

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Repository UI

Review profile: ASSERTIVE

Plan: Pro Plus

Run ID: a3d7d4c2-fbda-48a2-afec-b6b25438b70a

📥 Commits

Reviewing files that changed from the base of the PR and between b956be1 and 1fd0ea7.

📒 Files selected for processing (1)
  • documentation/resource_server.md

"file": file,
},
format="multipart",
headers={"Authorization": f"Bearer {access_token}"},

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

🎯 Functional Correctness | 🟠 Major | ⚡ Quick win

🧩 Analysis chain

🏁 Script executed:

#!/bin/bash
set -euo pipefail

rg -n -C 6 'requests\.(post|get|request)\(|format="multipart"|files=|DOCS_API' . \
  --glob '*.py' --glob '*.md'

Repository: suitenumerique/docs

Length of output: 50377


🏁 Script executed:

#!/bin/bash
set -euo pipefail

printf '--- documentation/resource_server.md import/context ---\n'
sed -n '1,110p' documentation/resource_server.md

printf '\n--- install-only requests availability ---\n'
python3 - <<'PY'
try:
    import requests
    from requests.structures import CaseInsensitiveDict
    from io import BytesIO

    files = {"file": BytesIO(b"hello").__class__(BytesIO(b"hello"), name="readme.md")}
    req = requests.Request('POST', 'http://example.invalid/', files=files, headers={"Authorization": "Bearer token"})
    prepared = req.prepare()
    print(prepared.headers.get("Content-Type"))
    body = prepared.body
    print(isinstance(prepared.body, requests.structures.CaseInsensitiveDict))
    if body is not None and not isinstance(body, requests.models.PreparedRequest):
        # inspect header bytes without printing payload boundary
        print(body[:body.find(b"--") + 20] if isinstance(body, bytes) else str(type(body)))
except Exception as e:
    print(type(e).__name__, str(e))
PY

printf '\n--- requests.post signature ---\n'
python3 - <<'PY'
import inspect
import requests
sig = inspect.signature(requests.Session.post)
print(sig)
print(requests.Session.post.__doc__.splitlines()[:12] if requests.Session.post.__doc__ else "no doc")
PY

printf '\n--- inspect requests Session.post source line numbers ---\n'
python3 - <<'PY'
import inspect, requests
srcfile = inspect.getsourcefile(requests.Session.post)
sourcelines = inspect.getsourcelines(requests.Session.post)
print(srcfile, sourcelines[1])
PY

Repository: suitenumerique/docs

Length of output: 248


🏁 Script executed:

#!/bin/bash
set -euo pipefail

printf '%s\n' '--- documentation/resource_server.md import/context ---'
sed -n '1,110p' documentation/resource_server.md

printf '%s\n' '--- install-only requests availability ---'
python3 - <<'PY'
try:
    import requests
    from requests.structures import CaseInsensitiveDict
    from io import BytesIO

    files = {"file": BytesIO(b"hello").__class__(BytesIO(b"hello"), name="readme.md")}
    req = requests.Request('POST', 'http://example.invalid/', files=files, headers={"Authorization": "Bearer token"})
    prepared = req.prepare()
    print(prepared.headers.get("Content-Type"))
    body = prepared.body
    print(isinstance(prepared.body, requests.structures.CaseInsensitiveDict))
    if body is not None and not isinstance(body, requests.models.PreparedRequest):
        print(body[:body.find(b"--") + 20] if isinstance(body, bytes) else str(type(body)))
except Exception as e:
    print(type(e).__name__, str(e))
PY

printf '%s\n' '--- requests.post signature ---'
python3 - <<'PY'
import inspect
import requests
sig = inspect.signature(requests.Session.post)
print(sig)
print(requests.Session.post.__doc__.splitlines()[:12] if requests.Session.post.__doc__ else "no doc")
PY

printf '%s\n' '--- inspect requests Session.post source locations ---'
python3 - <<'PY'
import inspect, requests
srcfile = inspect.getsourcefile(requests.Session.post)
sourcelines = inspect.getsourcelines(requests.Session.post)
print(srcfile, sourcelines[1])
PY

Repository: suitenumerique/docs

Length of output: 4528


Use files= for multipart uploads.

The Python Requests API does not accept a data dict or format="multipart"; these are Django test client arguments. Pass the file with files={"file": file} and remove format="multipart" so this copied snippet is valid Python code.

Proposed fix
 response = requests.post(
     f"{settings.DOCS_API}/documents/",
-    {
+    files={
         "file": file,
     },
-    format="multipart",
     headers={"Authorization": f"Bearer {access_token}"},
 )
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
headers={"Authorization": f"Bearer {access_token}"},
response = requests.post(
f"{settings.DOCS_API}/documents/",
files={
"file": file,
},
headers={"Authorization": f"Bearer {access_token}"},
)
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@documentation/resource_server.md` at line 90, Update the multipart upload
example in the documentation to use Requests’ files parameter with
files={"file": file}, and remove the unsupported format="multipart" argument
while preserving the Authorization header.

Source: MCP tools

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

Labels

documentation Improvements or additions to documentation

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants