Conversation
…s to it through JSON data payload instead
Codecov Report❌ Patch coverage is Additional details and impacted files@@ Coverage Diff @@
## main #906 +/- ##
==========================================
+ Coverage 55.42% 55.48% +0.06%
==========================================
Files 103 103
Lines 11546 11547 +1
Branches 1541 1541
==========================================
+ Hits 6399 6407 +8
+ Misses 4800 4793 -7
Partials 347 347 🚀 New features to boost your workflow:
|
…rides are only implemented when needed by the router; used a different visit name for the test
create_session API endpoint and perform housekeeping on murfey.server.api.session_info
tieneupin
marked this pull request as ready for review
October 1, 2026 14:38
| name=name, | ||
| visit=visit, | ||
| session = MurfeyDB.Session( | ||
| name=session_info.name, |
Contributor
There was a problem hiding this comment.
name definitely needs sanitising - I'd suggest stripping out anything except standard alphanumeric and _ or -
Contributor
Author
There was a problem hiding this comment.
Ok, I've tacked on the sanitise() function to both of them.
| visit=visit, | ||
| session = MurfeyDB.Session( | ||
| name=session_info.name, | ||
| visit=session_info.visit, |
Contributor
There was a problem hiding this comment.
probably also worth sanitising the visit in the same way
This branch has not been deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
NOTE: This PR will need to be deployed alongside DiamondLightSource/murfey-frontend#88
The
create_sessionFastAPI endpoint previously parsed thevisit(e.g. 'cm12345-6') andname(an optional long-form description) directly from the URL path. This is unsafe, as the presence of characters such as '/' in the parametrers will break the URL construction logic.This PR fixes that by passing the
visitandnameas part of the JSON data payload instead. The API endpoint path was also changed now thatvisitandnameare no longer needed as URL path parts.As part of housekeeping, the way in which the Murfey database tables were imported and called was also standardised. Instead of importing the tables directly, we use
import murfey.util.db as MurfeyDBand called tables fromMurfeyDB. Type hints were also replaced with more modern variants.A bug was also identified when seeding the database fixtures upon startup. For integer primary keys, if a value is manually provided as part of the initial insert, it does not update PostGreSQL's internal counter. Subsequent inserts where the primary key is allow to auto-increment will then attempt to insert into that database with the previous primary key, causing the insert to fail. By removing the primary key from the initial insert in the database fixture, the internal PostgreSQL counter is now updated correctly.