Skip to content

Conversation

@zimzoom
Copy link
Contributor

@zimzoom zimzoom commented Jan 12, 2026

Reverts #2366

Scope of this bug was larger than originally thought, reverting to be safe.

Summary by CodeRabbit

  • Refactor
    • Removed support for multipart form data uploads in search API request processing, which may impact form submissions using multipart encoding.
    • Simplified request body handling to use a unified processing method for all incoming requests, replacing previous conditional content-type logic.

✏️ Tip: You can customize this high-level summary in your review settings.

@coderabbitai
Copy link

coderabbitai bot commented Jan 12, 2026

📝 Walkthrough

Walkthrough

The pull request removes multipart form data parsing functionality from the CMR search routes, eliminating the parse-multipart-body function and its associated middleware pathway. Body handling is simplified to consistently use slurp for reading request bodies, with the multipart namespace dependency removed.

Changes

Cohort / File(s) Summary
Multipart handling removal
search-app/src/cmr/search/routes.clj
Deleted parse-multipart-body function; simplified copy-of-body-handler to always read body via slurp instead of conditionally checking content-type; removed ring.middleware.multipart-params namespace import

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~8 minutes

Possibly related PRs

Suggested reviewers

  • jmaeng72
  • jceaser

Poem

🐰 A simpler path the rabbit hops today,
Multipart forms hop far, far away!
Slurp and stream, no branching confuse,
Clean routes ahead—much less to peruse! ✨

🚥 Pre-merge checks | ✅ 2 | ❌ 1
❌ Failed checks (1 warning)
Check name Status Explanation Resolution
Description check ⚠️ Warning The description is minimal and lacks required sections from the template (Overview, What are the changes, What areas of the application does this impact, and checklists). Add required sections: Overview with objective, detailed list of changes, and impacted application areas. Include completed checklists for tests, linting, documentation, and code quality.
✅ Passed checks (2 passed)
Check name Status Explanation
Title check ✅ Passed The title clearly and specifically describes the main change: reverting a previous commit related to body-copy middleware and form data handling.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.

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


📜 Recent review details

Configuration used: defaults

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 23f93e6 and d78c8da.

📒 Files selected for processing (1)
  • search-app/src/cmr/search/routes.clj
🔇 Additional comments (1)
search-app/src/cmr/search/routes.clj (1)

64-68: Verify character encoding handling for non-ASCII request bodies.

The reverted implementation uses slurp and .getBytes without explicit charset specification. Both default to the platform encoding, which may not be UTF-8 on all systems. If request bodies contain non-ASCII characters (e.g., UTF-8 encoded collection names), this could cause data corruption on systems with non-UTF-8 default encodings.

Since this is reverting to a previous working state, this may be acceptable or mitigated elsewhere, but consider specifying UTF-8 explicitly:

Suggested encoding-safe approach
 (defn copy-of-body-handler
   "Copies the body into a new attribute called :body-copy so that after a post
   of form content type the original body can still be read. The default ring
   params reads the body and parses it and we don't have access to it."
   [handler]
   (fn [request]
-    (let [^String body (slurp (:body request))]
+    (let [^String body (slurp (:body request) :encoding "UTF-8")]
       (handler (assoc
                 request
                 :body-copy body
-                :body (java.io.ByteArrayInputStream. (.getBytes body)))))))
+                :body (java.io.ByteArrayInputStream. (.getBytes body "UTF-8")))))))

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.

@zimzoom zimzoom merged commit 2916c36 into master Jan 12, 2026
5 checks passed
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.

4 participants