Skip to content

[client-python] Strip trailing slash from URL before building API endpoint (#15973)#15972

Merged
ncarenton merged 2 commits into
masterfrom
fix/strip_trailing_slash
May 13, 2026
Merged

[client-python] Strip trailing slash from URL before building API endpoint (#15973)#15972
ncarenton merged 2 commits into
masterfrom
fix/strip_trailing_slash

Conversation

@jabesq

@jabesq jabesq commented May 12, 2026

Copy link
Copy Markdown
Member

requests 2.34.0 (psf/requests#7315) no longer normalizes duplicate leading slashes in URI paths. When OPENCTI_URL ends with '/', the naive concatenation url + '/graphql' produces '//graphql', which the server rejects as 'Path not found'. Using url.rstrip('/') ensures a clean path regardless of the requests version.

Proposed changes

Related issues

Checklist

  • I consider the submitted work as finished
  • I tested the code for its functionality
  • I wrote test cases for the relevant uses case (coverage and e2e)
  • I added/update the relevant documentation (either on github or on notion)
  • Where necessary I refactored code to improve the overall quality

Further comments

@github-actions github-actions Bot added the filigran team Item from the Filigran team. label May 12, 2026
@jabesq jabesq changed the title [client-python] Strip trailing slash from URL before building API endpoint [client-python] Strip trailing slash from URL before building API endpoint (#15973) May 12, 2026
@codecov

codecov Bot commented May 12, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 34.49%. Comparing base (eb173e7) to head (0597f34).
⚠️ Report is 1 commits behind head on master.

Additional details and impacted files
@@           Coverage Diff           @@
##           master   #15972   +/-   ##
=======================================
  Coverage   34.49%   34.49%           
=======================================
  Files        3254     3254           
  Lines      220135   220135           
  Branches    40872    40873    +1     
=======================================
+ Hits        75935    75938    +3     
+ Misses     144200   144197    -3     
Flag Coverage Δ
opencti-client-python 46.36% <100.00%> (ø)
opencti-front 3.42% <ø> (ø)
opencti-graphql 71.32% <ø> (+<0.01%) ⬆️

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@ncarenton ncarenton requested a review from aHenryJard May 12, 2026 15:51
@aHenryJard aHenryJard self-assigned this May 13, 2026
jabesq added 2 commits May 13, 2026 10:16
…point

requests 2.34.0 (#7315) no longer normalizes duplicate leading slashes
in URI paths. When OPENCTI_URL ends with '/', the naive concatenation
url + '/graphql' produces '//graphql', which the server rejects as
'Path not found'. Using url.rstrip('/') ensures a clean path regardless
of the requests version.
@jabesq jabesq force-pushed the fix/strip_trailing_slash branch from ac36cbe to 0597f34 Compare May 13, 2026 08:16

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

Tested locally with a pycti script and using and api_url with 2 // at the end, working all fine.
Also tested with a not empty base_path on opencti.

@ncarenton ncarenton merged commit e84dd12 into master May 13, 2026
57 of 58 checks passed
@ncarenton ncarenton deleted the fix/strip_trailing_slash branch May 13, 2026 10:19
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

filigran team Item from the Filigran team.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[BUG] [client-python] API URL construction breaks with requests 2.34.0 when OPENCTI_URL has a trailing slash

3 participants