-
Notifications
You must be signed in to change notification settings - Fork 4k
Fix for query param issue with base url #2894
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hi @sachitv, thanks so much for your contribution!
The general approach to this fix is correct, but there are a few details that I think need to be ironed out before this can be merged. Please see my comments below.
Additionally, it'd be great if you could add some unit tests for the handlePageInfoChanged method to App.test.tsx to make it less likely that a regression causes this issue to happen again. The tests should be added into a new App.handlePageInfoChanged describe block and will likely be structurally similar to the existing App.handleNewReport tests. We'll want to check four cases:
/pathname with no query string/pathname with a query string- non-
/pathname with no query string - non-
/pathname with a query string
Feel free to ask me if you happen to have any questions about adding tests!
frontend/src/App.tsx
Outdated
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Two things to note about these lines:
- It's fine to use relative URLs with
pushState, so I think we'll want to do that and thus dropdocument.location.originhere for conciseness. - This will always evaluate to
?${queryString}since by javascript operator precedence, this is equivalent to
(document.location.origin + document.location.pathname + queryString) ? `?${queryString}` : "/"I believe we want to do something like
const targetUrl = document.location.pathname + (queryString ? `?${queryString}` : "")where we can drop the / in the ternary operator as it'll come from pathname.
|
Thanks for the feedback @vdonato . I’ll make the changes this week and add the unit tests as well. |
|
This pull request has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions. |
|
Sorry for the delay, I have been able to make your fixes locally. Though when it comes to creating the unit tests, I might need to specify additional configuration options for these tests namely: --server.baseUrlPath="foobar"I noticed that there's no generic way to pass parameters for individual test cases. Would there be an objection to adding something like this? I was thinking of creating special folder called 'extra_parameters' alongside scripts and specs in the e2e folder. This would basically contain some .txt files containing text like the above, which is read and passed as command line parameters to the streamlit invocation. I was wondering if I could use a special toml file here instead? Thoughts @vdonato ? |
|
Alternatively I could just move my scripts into some sort of 'special' folder and handle the arguments on a case by case basis. Just looking for some guidance on what would be the best path forward. |
|
Hey @sachitv, no worries about the delay. As far as testing goes, I think writing tests at the level where we're setting An approach that will be both easier and more practical given the size of the
I listed out some of the cases we want to test in a previous comment. |
5d1dc1c to
c0bdaa7
Compare
|
Thanks for the feedback @vdonato , please can you have a look at these changes? Given i'm not really a TypeScript programmer, I apologize in advance if this freaks you out. |
f4bceef to
b3375f9
Compare
vdonato
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hey @sachitv, this looks good to me! I have a few small stylistic points to bring up in the tests, but they're all minor.
Once those are fixed, I can get a second reviewer to take a look (we generally require two people to look at community contributions), and we'll be able to get these changes merged.
This fixes streamlit#2887. Also adds unit tests to App.test.tsx.
b3375f9 to
59288c7
Compare
|
Hi Vincent, Appreciate the feedback. I've addressed all your requested changes. Hopefully in a good state to add a second reviewer now? |
vdonato
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks good to me, thanks for your work on this @sachitv!
I'll ping people to have a second reviewer take a look on Monday (there's a company hackathon going on right now so I'd imagine everyone is heads down on their projects 🙂)
My pleasure.
Nice, have fun! Btw how does the release process work? Would it be possible to get a minor version release after this merged or would we have to wait for the next scheduled release? It would be really nice to have these fixes available for my work project. |
We do occasionally do patch releases for issues that sneak in that are especially bad, but I think for an issue of this severity being fixed, it'll be included in the next scheduled release on April 8 (there don't seem to be too many people running into #2887). Note that if you really need it earlier and are okay with dealing with the potential for a bit of instability, we auto-publish a streamlit-nightly package that'll include this change the next time it's built after this PR is merged. |
|
Thanks for the response. I think I can wait until April 8 for the next scheduled release. |
ghost
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks good to me!
|
Thanks @bh-streamlit and @vdonato for the review. Unfortunately I don't have the bits to merge this. Please could you hit the green button for me? |
|
@sachitv merged! Thanks again for your work! |
* develop: Set baseUrl to . Speed up CircleCI more (#3025) Add events to keep track of theme changes and other theme stats (#3012) Have MetricsManager enqueue events when disconnected (#3011) Fix for query param issue with base url (#2894) Add fuzzy search to selectbox (#2933) Informative repr methods for our python classes (#3027) ComponentInstance: handle iframe changes (#3015)
* st_form: Set baseUrl to . Speed up CircleCI more (streamlit#3025) Add events to keep track of theme changes and other theme stats (streamlit#3012) Have MetricsManager enqueue events when disconnected (streamlit#3011) Fix for query param issue with base url (streamlit#2894) Add fuzzy search to selectbox (streamlit#2933) Informative repr methods for our python classes (streamlit#3027) ComponentInstance: handle iframe changes (streamlit#3015)

This fixes #2887.