Skip to content

fix: normalize URL parts in _build_url to prevent malformed URLs#41

Merged
Prashant-Surya merged 1 commit into
mainfrom
fix-build-url
May 28, 2026
Merged

fix: normalize URL parts in _build_url to prevent malformed URLs#41
Prashant-Surya merged 1 commit into
mainfrom
fix-build-url

Conversation

@akhil-vamshi-konam
Copy link
Copy Markdown
Contributor

@akhil-vamshi-konam akhil-vamshi-konam commented May 28, 2026

Description

Normalized base_path and endpoint strings in _build_url() to prevent malformed URLs caused by redundant or missing slashes.

This change:

  • strips trailing / from config.base_path
  • strips leading/trailing / from endpoints
  • ensures consistent URL generation regardless of caller input

Example:

Before:

config.base_path = "https://api.example.com/"
endpoint = "releases/"

Generated:

https://api.example.com//workspaces/releases//

After:

https://api.example.com/workspaces/releases/

Type of Change

  • Bug fix (non-breaking change which fixes an issue)
  • Improvement (change that would cause existing functionality to not work as expected)

Summary by CodeRabbit

  • Bug Fixes
    • Improved API request URL construction and path normalization to ensure consistent handling of leading and trailing slashes in both endpoint configurations and base path settings. This enhancement reduces the risk of routing errors and ensures more reliable, consistently formatted request paths across all API interactions throughout the system.

Review Change Stack

@coderabbitai
Copy link
Copy Markdown

coderabbitai Bot commented May 28, 2026

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: 1f74a15d-79e2-45f1-ad79-b86043aff6f0

📥 Commits

Reviewing files that changed from the base of the PR and between 88ade49 and a0e0e2d.

📒 Files selected for processing (1)
  • plane/api/base_resource.py

📝 Walkthrough

Walkthrough

The BaseResource._build_url() method updates URL path normalization by changing endpoint handling from lstrip("/") to strip("/") to remove both leading and trailing slashes, and ensures the base_path prefix is normalized by stripping trailing slashes before concatenation.

Changes

URL Construction Normalization

Layer / File(s) Summary
URL path normalization in _build_url()
plane/api/base_resource.py
_build_url() changes endpoint normalization from lstrip("/") to strip("/") to handle both leading and trailing slashes, and uses self.config.base_path.rstrip('/') to remove trailing slashes from the base path before URL concatenation.

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~10 minutes

Poem

A path so clean, both ends aligned,
The trailing slash no longer pined—
With strip() and rstrip() in place,
URLs find their rightful space! 🐰✨

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The pull request title accurately and specifically describes the main change: normalizing URL parts in _build_url to prevent malformed URLs.
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.

✏️ 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 fix-build-url

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.

@coderabbitai
Copy link
Copy Markdown

coderabbitai Bot commented May 28, 2026

Actionable comments posted: 0

@Prashant-Surya Prashant-Surya merged commit 3e0e257 into main May 28, 2026
1 check passed
@Prashant-Surya Prashant-Surya deleted the fix-build-url branch May 28, 2026 12:01
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.

2 participants