-
Notifications
You must be signed in to change notification settings - Fork 3
Hotfix for using subproviders #1182
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
WalkthroughThe sub_provider form field is reorganized across Sofia account modals: removed from the edit modal and conditionally added to the new account user modal when the subprovider configuration is present. Changes
Estimated code review effort🎯 2 (Simple) | ⏱️ ~8 minutes
Possibly related PRs
Poem
Pre-merge checks and finishing touches❌ Failed checks (1 warning)
✅ Passed checks (2 passed)
✨ Finishing touches🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. 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.
Pull request overview
This is a hotfix that corrects the placement of the subprovider input field in user modals. The code was accidentally removed from the edit modal and is now being properly added to the new user modal instead.
Key Changes:
- Adds subprovider input field to the new Sofia account user modal (conditionally shown when subprovider_label is configured)
- Removes subprovider input field from the edit Sofia account modal
Reviewed changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated 1 comment.
| File | Description |
|---|---|
| app/views/users/_new_sofia_account_user_modal.html.erb | Adds conditional subprovider field to new user form |
| app/views/users/_edit_sofia_account_modal.html.erb | Removes subprovider field from edit user form |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| <%= f.input :name, label: 'Naam', placeholder: 'Naam', required: true %> | ||
| <%= f.input :email, label: 'E-mailadres', placeholder: 'E-mailadres', required: true %> | ||
| <% if Rails.application.config.x.subprovider_label.present? %> | ||
| <%= f.input :sub_provider, label: 'Subprovider', placeholder: Rails.application.config.x.subprovider_label, required: true, input_html: { style: 'text-transform: uppercase;', onkeyup: 'this.value = this.value.toUpperCase();' } %> |
Copilot
AI
Dec 19, 2025
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.
The label for the sub_provider field uses 'Subprovider', but in the code that was removed from the edit modal, it was 'SubProvider' (with capital P). This inconsistency should be corrected to match the original capitalization for consistency.
| <%= f.input :sub_provider, label: 'Subprovider', placeholder: Rails.application.config.x.subprovider_label, required: true, input_html: { style: 'text-transform: uppercase;', onkeyup: 'this.value = this.value.toUpperCase();' } %> | |
| <%= f.input :sub_provider, label: 'SubProvider', placeholder: Rails.application.config.x.subprovider_label, required: true, input_html: { style: 'text-transform: uppercase;', onkeyup: 'this.value = this.value.toUpperCase();' } %> |
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.
Actionable comments posted: 1
📜 Review details
Configuration used: defaults
Review profile: CHILL
Plan: Pro
📒 Files selected for processing (2)
app/views/users/_edit_sofia_account_modal.html.erb(0 hunks)app/views/users/_new_sofia_account_user_modal.html.erb(1 hunks)
💤 Files with no reviewable changes (1)
- app/views/users/_edit_sofia_account_modal.html.erb
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (1)
- GitHub Check: Build
| <% if Rails.application.config.x.subprovider_label.present? %> | ||
| <%= f.input :sub_provider, label: 'Subprovider', placeholder: Rails.application.config.x.subprovider_label, required: true, input_html: { style: 'text-transform: uppercase;', onkeyup: 'this.value = this.value.toUpperCase();' } %> | ||
| <% end %> |
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.
🧩 Analysis chain
🏁 Script executed:
#!/bin/bash
# Check User model for sub_provider validations
echo "=== Searching for sub_provider validations in User model ==="
rg -n 'validates.*sub_provider|presence.*sub_provider' app/models/ || echo "No validates directive found"
# Check for sub_provider in entire models directory
echo "=== All sub_provider references in models ==="
rg -n -B 2 -A 2 'sub_provider' app/models/ || echo "No sub_provider references found"
# Check for uppercase/upcase handling for sub_provider
echo "=== Checking for uppercase normalization ==="
rg -n -B 2 -A 2 'upcase|uppercase' app/models/ app/controllers/ | grep -A 2 -B 2 'sub_provider\|provider' || echo "No uppercase handling found"
# List the edit modal file to verify it exists
echo "=== Checking edit modal file ==="
fd '_edit_sofia_account_modal' app/views/users/
# Check sub_provider in edit modal
echo "=== Checking if sub_provider exists in edit modal ==="
if [ -f "app/views/users/_edit_sofia_account_modal.html.erb" ]; then
rg -n 'sub_provider' app/views/users/_edit_sofia_account_modal.html.erb || echo "No sub_provider found in edit modal"
else
echo "Edit modal file not found"
fi
# Get context of the new modal around the sub_provider field
echo "=== Context of new modal (lines 14-20) ==="
sed -n '14,20p' app/views/users/_new_sofia_account_user_modal.html.erbRepository: csvalpha/sofia
Length of output: 1048
🏁 Script executed:
#!/bin/bash
# Check User model file to see full structure
echo "=== User model existence ==="
fd 'user.rb' app/models/ | head -5
# Check if sub_provider is an accessor or attribute
echo "=== Checking User model for sub_provider attribute/accessor ==="
rg -n 'attr_|sub_provider' app/models/user.rb
# Check strong parameters/permit list in controller
echo "=== Checking controller for sub_provider in params permit ==="
rg -n -B 3 -A 3 'permit.*sub_provider|params\[:user\]' app/controllers/ | grep -B 3 -A 3 'sub_provider\|user_params' || echo "Checking for user controller..."
# Find user-related controllers
echo "=== Finding user-related controllers ==="
fd 'users_controller' app/controllers/Repository: csvalpha/sofia
Length of output: 1300
🏁 Script executed:
#!/bin/bash
# Read the entire User model
echo "=== Full User model ==="
head -80 app/models/user.rb
# Check for database schema/migrations
echo "=== Checking schema for sub_provider column ==="
rg -n 'sub_provider' db/schema.rb || echo "Not in schema.rb"
# Check recent migrations for sub_provider
echo "=== Checking migrations for sub_provider ==="
fd 'migrate' db/migrate | xargs rg -l 'sub_provider' | head -5
# If migrations found, show content
echo "=== Migration content ==="
fd 'migrate' db/migrate | xargs rg -B 2 -A 2 'sub_provider' || echo "No sub_provider in migrations"Repository: csvalpha/sofia
Length of output: 6123
Add presence validation and backend normalization for sub_provider field
The sub_provider field is now in the new modal with required: true, but the User model lacks critical backend safeguards:
- Missing presence validation: No
validates :sub_provider, presence: truein the User model, despite the form marking it as required. - Missing backend normalization: No backend uppercasing logic exists—only client-side
onkeyuphandler enforcement, which users can bypass. - Data integrity risk: Without backend validation and normalization, submitted data may be lowercase, contradicting the UI intent.
Add to the User model:
validates :sub_provider, presence: true, if: -> { Rails.application.config.x.subprovider_label.present? }
before_save { self.sub_provider = sub_provider.upcase if sub_provider.present? }Remove the onkeyup handler from the form if backend normalization is added, or keep it for UX consistency but ensure the backend is the source of truth.
🤖 Prompt for AI Agents
In app/views/users/_new_sofia_account_user_modal.html.erb around lines 16-18,
the form marks :sub_provider as required but the User model lacks backend
presence validation and normalization; add a conditional presence validation
(only when Rails.application.config.x.subprovider_label.present?) and a
before_save callback to upcase sub_provider if present so the database always
stores uppercase values; after adding backend normalization you may remove the
client-side onkeyup handler from the form (or keep it for UX) since the backend
will be the source of truth.
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## staging #1182 +/- ##
========================================
Coverage 77.62% 77.62%
========================================
Files 54 54
Lines 1341 1341
========================================
Hits 1041 1041
Misses 300 300 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
I accidentally removed the code from the right place, and didn't test afterwards
Summary by CodeRabbit
New Features
Bug Fixes
✏️ Tip: You can customize this high-level summary in your review settings.