Fix: Replace URL-based error messages with secure Flask flash messages#11
Closed
Copilot wants to merge 3 commits into
Closed
Fix: Replace URL-based error messages with secure Flask flash messages#11Copilot wants to merge 3 commits into
Copilot wants to merge 3 commits into
Conversation
Co-authored-by: tak-s <20725737+tak-s@users.noreply.github.com>
Copilot
AI
changed the title
[WIP] [Improve] エラーメッセージの扱い
Fix: Replace URL-based error messages with secure Flask flash messages
Jul 16, 2025
tak-s
requested changes
Jul 16, 2025
Owner
tak-s
left a comment
There was a problem hiding this comment.
エラーメッセージだけのために、シークレットキーを用意するのは避けたい。他の方法を検討して
…t key requirement) Co-authored-by: tak-s <20725737+tak-s@users.noreply.github.com>
Contributor
Author
シークレットキーを削除し、代わりに事前定義されたメッセージコードシステムに変更しました。これにより:
セキュリティテスト済みで、無効なメッセージコードは全て拒否されます。 コミット: 9670b32 |
Owner
|
不採用 |
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.
Issue
Error messages were being passed through URL query parameters, making them easily manipulable by users and creating security/UX issues:
Before:
http://localhost:5000/create_dataset?error=データセット名を入力してください。Solution
Replaced URL query parameter-based messaging with Flask's secure session-based flash messaging system.
After:
http://localhost:5000/create_dataset(message securely stored in server-side session)Key Changes
1. Added Session Support
2. Replaced URL Parameter Messages
Before:
After:
3. Updated Template System
Before: Templates received
messageandmessage_typevariables from routesAfter: Templates use Flask's built-in
get_flashed_messages(with_categories=true):{% with messages = get_flashed_messages(with_categories=true) %} {% if messages %} {% for category, message in messages %} <div class="alert alert-{{ 'danger' if category == 'error' else 'success' }}"> {{ message }} </div> {% endfor %} {% endif %} {% endwith %}Security Benefits
Testing
Comprehensive testing confirmed:
- URL parameters no longer affect displayed messages
- All error and success scenarios work correctly
- Messages appear exactly once and don't persist incorrectly
- Application maintains all existing functionality
Screenshot showing secure error message display with clean URL (no query parameters)
Fixes #10.
💡 You can make Copilot smarter by setting up custom instructions, customizing its development environment and configuring Model Context Protocol (MCP) servers. Learn more Copilot coding agent tips in the docs.