-
Notifications
You must be signed in to change notification settings - Fork 2
fix: Add validation to prevent duplicate adapter names #263
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
Open
dittops
wants to merge
3
commits into
master
Choose a base branch
from
claude/issue-251-20250827-0616
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from 2 commits
Commits
Show all changes
3 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
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
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
Oops, something went wrong.
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.
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.
[P1] Handle multiple case-insensitive matches gracefully
The new call to
retrieve_by_fields(..., case_sensitive=False)now collapses name comparison to lowercase, butretrieve_by_fieldsstill usesscalar_one_or_none. If the database already contains two adapters whose names differ only by casing (e.g."Adapter"and"adapter", which was previously allowed because validation was case-sensitive), this query will now raiseMultipleResultsFoundand bubble up as a 500 instead of returning aClientException. The change prevents new duplicates, but it makes the API fail for existing data rather than surfacing a user-facing validation error. Consider retrieving all matches or constraining the query to a single row before raising the custom exception.Useful? React with 👍 / 👎.
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.
@claude what's your take on this?
Uh oh!
There was an error while loading. Please reload this page.
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.
Claude finished @dittops's task —— View job
Analyzing the Codex review concern about case-insensitive validation...
Todo List
Analysis and Assessment
Codex is absolutely correct about this concern. Here's the detailed analysis:
The Problem
Current Behavior: The code uses
retrieve_by_fields(..., case_sensitive=False)which callsscalar_one_or_none()on the database query.SQLAlchemy's scalar_one_or_none() Behavior: This method will raise
sqlalchemy.exc.MultipleResultsFoundif the query returns more than one row.The Edge Case: If the database already contains adapters with names that differ only by case (e.g., "Adapter" and "adapter"), the case-insensitive query
func.lower(field) == func.lower(value)would match both records.Current Problem: Instead of getting a user-friendly validation error, users would get a 500 error with
MultipleResultsFoundexception.Database Schema Analysis
Looking at the adapter table creation in migration
35c352d33c91_adapter_table_workflow_type.py, I can see:(name, endpoint_id)combinationThe Risk
This is a real production risk because:
MultipleResultsFoundinstead of providing helpful validationRecommendation
Option 1: Robust Query Approach (Recommended)
Replace the current logic with:
Option 2: Try-Catch Approach
Wrap the current code in try-catch to handle
MultipleResultsFound:I recommend Option 1 as it's cleaner and more explicit about the intention.