Skip to content
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

page_link and switch_page with / prefixed path is incorrectly treated as relative path #8081

Closed
3 of 4 tasks
sfc-gh-jcarroll opened this issue Feb 5, 2024 · 1 comment · Fixed by #8085
Closed
3 of 4 tasks
Labels
feature:st.page_link feature:st.switch_page priority:P2 status:confirmed Bug has been confirmed by the Streamlit team type:bug Something isn't working

Comments

@sfc-gh-jcarroll
Copy link
Collaborator

Checklist

  • I have searched the existing issues for similar issues.
  • I added a very descriptive title to this issue.
  • I have provided sufficient information below to help reproduce this issue.

Summary

If I do st.page_link("/pages/page2.py"), this is treated as a relative path from the main app file, instead of an absolute path. This is unintuitive, since / prefixed file paths are usually treated as absolute from the root folder.

The same behavior is also true for st.switch_page()

Reproducible Code Example

import streamlit as st

# Assuming I have a relative page at `pages/page2.py`, this link will work
# I'd expect it to fail
st.page_link("/pages/page2.py")

Steps To Reproduce

Run the app above, see that it works

Expected Behavior

Throw an error since there's no /pages/page2.py from the root

Current Behavior

No error, it works (unexpectedly)

Is this a regression?

  • Yes, this used to work in a previous version.

Debug info

  • Streamlit version: 1.31
  • Python version: 3.11
  • Operating System: Mac
  • Browser: N/A

Additional Information

No response

@sfc-gh-jcarroll sfc-gh-jcarroll added type:bug Something isn't working status:needs-triage Has not been triaged by the Streamlit team labels Feb 5, 2024
Copy link

github-actions bot commented Feb 5, 2024

If this issue affects you, please react with a 👍 (thumbs up emoji) to the initial post.

Your feedback helps us prioritize which bugs to investigate and address first.

Visits

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
feature:st.page_link feature:st.switch_page priority:P2 status:confirmed Bug has been confirmed by the Streamlit team type:bug Something isn't working
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants