Skip to content

refactor: standardize root_path access to settings.app_root_path#3875

Open
Yosiefeyob wants to merge 3 commits intomainfrom
root-path-refactor
Open

refactor: standardize root_path access to settings.app_root_path#3875
Yosiefeyob wants to merge 3 commits intomainfrom
root-path-refactor

Conversation

@Yosiefeyob
Copy link
Copy Markdown
Collaborator

@Yosiefeyob Yosiefeyob commented Mar 26, 2026

🔗 Related Issue

Closes #1588


📝 Summary

What does this PR do and why?
Replaces all request.scope.get("root_path", "") calls with settings.app_root_path across files.

Redirect URLs to /admin were also updated to use a consistent trailing slash (/admin/) to avoid unnecessary 307 redirects from FastAPI's path normalization.

Tests were updated to patch settings.app_root_path directly instead of injecting root_path via the request scope, which aligns with the new standardized pattern and makes tests easier to maintain.

The existing _resolve_root_path helper in admin.py was preserved as-is since it intentionally reads from the request scope first (for proxy/mounted deployments) and falls back to settings.app_root_path — this links to PR #1547.


🏷️ Type of Change

  • Bug fix
  • Feature / Enhancement
  • Documentation
  • Refactor
  • Chore (deps, CI, tooling)
  • Other (describe below)

🧪 Verification

Check Command Status
Lint suite make lint
Unit tests make test
Coverage ≥ 80% make coverage

✅ Checklist

  • Code formatted (make black isort pre-commit)
  • Tests added/updated for changes
  • Documentation updated (if applicable)
  • No secrets or credentials committed

@Yosiefeyob Yosiefeyob added the chore Linting, formatting, dependency hygiene, or project maintenance chores label Mar 26, 2026
@Yosiefeyob Yosiefeyob modified the milestone: Release 1.2.0 Mar 26, 2026
@Yosiefeyob Yosiefeyob modified the milestone: Release 1.2.0 Mar 26, 2026
@Yosiefeyob Yosiefeyob marked this pull request as ready for review March 26, 2026 15:31
@crivetimihai crivetimihai added the SHOULD P2: Important but not vital; high-value items that are not crucial for the immediate release label Mar 29, 2026
@crivetimihai
Copy link
Copy Markdown
Member

Thanks @Yosiefeyob. Clean refactor — using request.scope.get("root_path", "") is more resilient and aligns with ASGI conventions. Please add the DCO Signed-off-by line to your commit.

@Yosiefeyob Yosiefeyob force-pushed the root-path-refactor branch 3 times, most recently from 44dd8d0 to cde44d7 Compare April 8, 2026 12:33
Signed-off-by: Yosief Eyob <yosiefogbazion@gmail.com>
Signed-off-by: Yosief Eyob <yosiefogbazion@gmail.com>
Signed-off-by: Yosief Eyob <yosiefogbazion@gmail.com>
@Yosiefeyob Yosiefeyob force-pushed the root-path-refactor branch from 92d9cce to 1e4931e Compare April 9, 2026 09:33
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

chore Linting, formatting, dependency hygiene, or project maintenance chores SHOULD P2: Important but not vital; high-value items that are not crucial for the immediate release

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[CHORE][REFACTOR]: Standardize root_path access pattern across codebase

3 participants