-
Notifications
You must be signed in to change notification settings - Fork 47
Description
hacktoberfest, good-first-issue, bug, help-wanted, priority-high
📋 Description
The Passenger Route Planner currently lacks proper error handling when attempting to find routes between stations. If the metro network graph becomes disconnected or if users select stations with no available path, the application crashes with an unhandled NetworkXNoPath exception.
This is a critical bug that affects user experience and application stability.
🔍 Current Behavior
When users select a start and destination station that are not connected in the network graph (lines 81-82), the application throws:
networkx.exception.NetworkXNoPath: No path between [Station A] and [Station B]
This results in a crashed Streamlit app with no user-friendly error message.
✅ Expected Behavior
The application should:
Gracefully handle cases where no route exists between selected stations
Display a user-friendly error message
Suggest checking station connectivity or trying alternative stations
Continue running without crashing
💡 Proposed Solution
Add proper exception handling around the pathfinding logic:
pythontry:
path = nx.shortest_path(G, source=start, target=end, weight="distance")
distance = nx.shortest_path_length(G, source=start, target=end, weight="distance")
# ... rest of the route planning logic
except nx.NetworkXNoPath:
st.error(f"❌ No route available between {start} and {destination}.")
st.info("💡 This might happen if stations are not connected. Please try different stations.")
except Exception as e:
st.error(f"
📍 Additional Improvements (Optional)
While fixing this issue, we could also:
Add validation to check graph connectivity on app load
Display a network connectivity status indicator
Show alternative route suggestions if available
Log errors for debugging purposes
🎯 Impact
User Experience: Prevents application crashes and provides clear feedback
Reliability: Makes the app more robust and production-ready
Maintainability: Sets a pattern for error handling across the codebase
🔧 Technical Details
File: app.py (or main application file)
Lines affected: 80-87
🙋♂️ Assignment Request
Hi maintainers! 👋
I would like to work on this issue as part of Hacktoberfest 2024 and GSSoC (if applicable). I have reviewed the codebase and understand the problem. I'm confident I can deliver a quality fix with proper error handling and user experience improvements.
My approach:
Add comprehensive exception handling for NetworkX path operations
Create informative, user-friendly error messages
Test thoroughly with edge cases
Update documentation if needed
Could you please assign this issue to me? I can start working on it immediately and submit a PR within 2-3 days.
GitHub Username: @shupandee
🏷️ Related Issues
This fix could be extended to address similar error handling gaps throughout the application
Could be paired with input validation improvements (separate issue)
📚 References
NetworkX Documentation: Exception Handling
Streamlit Error Display: st.error()
Thank you for considering this issue! Looking forward to contributing to WardhaMetroFlow! 🚇