Skip to content

fix: add missing SetupSurveyResponse model#22

Closed
pastoriniMatheus wants to merge 5 commits into
developfrom
fix/evolution-go-api-integration-issues
Closed

fix: add missing SetupSurveyResponse model#22
pastoriniMatheus wants to merge 5 commits into
developfrom
fix/evolution-go-api-integration-issues

Conversation

@pastoriniMatheus
Copy link
Copy Markdown

@pastoriniMatheus pastoriniMatheus commented May 13, 2026

Summary

User model declares has_one :setup_survey_response but the model file was missing, causing NameError on login after setup wizard completion.

Changes

  • Added app/models/setup_survey_response.rb with belongs_to :user

Test plan

  • Login succeeds without NameError
  • setup_survey_completed? returns false for new users

Summary by Sourcery

Add the missing SetupSurveyResponse ActiveRecord model to align with the existing user association.

New Features:

  • Introduce the SetupSurveyResponse model associated with User for storing setup survey responses.

Bug Fixes:

  • Resolve NameError on login by defining the SetupSurveyResponse model referenced by User.

marcelogorutuba and others added 4 commits May 4, 2026 17:01
…CE_URL config (#10)

* feat: onboarding survey backend — token, endpoint, user associations

- setup_bootstrap_service.rb: generate one-time survey_token (Redis, 10 min TTL)
  and return it in bootstrap response
- setup_controller.rb: add POST /setup/survey endpoint authenticated via
  X-Survey-Token header; falls back to authenticated endpoint after login
- user.rb: add user_tours and setup_survey_response associations +
  setup_survey_completed? helper
- serializers: expose setup_survey_completed and avatar_url on user payload
- profiles_controller.rb: invalidate token cache on avatar update
- avatarable.rb: add expires_in: 1.week to blob.url for cloud storage
- cors.rb: allow all origins on /rails/active_storage/* (public media blobs)
- development.rb: add docker service hostnames (evo-auth, evo-crm, etc.)
- routes.rb: add /setup/survey, user_tours and setup_survey resources

Co-Authored-By: Claude Sonnet 4.6 <[email protected]>

* fix(EVO-976): fix avatar_url returning relative path — add AUTH_SERVICE_URL config

Problem: avatarable.rb used rails_service_blob_proxy_path (relative path).
The browser resolved the path against the frontend origin (localhost:5173),
not the auth service (localhost:3001), causing consistent 404 on avatar load.

Changes:
- avatarable.rb: build absolute URL by prepending app_url config to the proxy path
- environment_config.rb: read AUTH_SERVICE_URL from env (default: http://localhost:3001)
  and configure Rails.application.routes.default_url_options accordingly,
  matching the same pattern already used by evo-ai-crm-community via BACKEND_URL
- development.rb: fix action_mailer.default_url_options port 3000 → 3001
  (was incorrectly pointing to the CRM service)

Co-Authored-By: Claude Sonnet 4.6 <[email protected]>

* fix(EVO-976): address round 2 code review (H3, H4, L1)

- avatarable.rb: extract AVATAR_URL_TTL constant (1.hour, was 1.week) so
  signed URLs that leak via logs/CDN/cache age out fast (H3 — info
  disclosure window 7d → 1h)
- avatarable.rb: rescue StandardError now returns nil instead of '' so the
  frontend doesn't render <img src=""> (which makes a request against the
  current page per HTML spec) when the URL helper raises (H4)
- avatarable.rb: also return nil (instead of '') when avatar is not attached
  — keeps return type consistent so serializers can null-check safely
- environment_config.rb: validate URI scheme is http(s) and host is present
  before configuring routes.default_url_options (URI.parse accepts schemeless
  strings like "auth.example.com" without raising InvalidURIError, which would
  otherwise leave default_url_options[:protocol] = nil) (L1)

Co-Authored-By: Claude Opus 4.7 (1M context) <[email protected]>

---------

Co-authored-by: Claude Sonnet 4.6 <[email protected]>
Co-authored-by: Davidson Gomes <[email protected]>
User model declares has_one :setup_survey_response but the model file
was missing, causing NameError on login. Added the model class to
unblock authentication flow.
@sourcery-ai
Copy link
Copy Markdown

sourcery-ai Bot commented May 13, 2026

Reviewer's guide (collapsed on small PRs)

Reviewer's Guide

Adds the missing SetupSurveyResponse ActiveRecord model to match the existing User.has_one association and wire it to users via belongs_to.

File-Level Changes

Change Details Files
Introduce SetupSurveyResponse model wired to User via belongs_to association.
  • Create SetupSurveyResponse ActiveRecord model class inheriting from ApplicationRecord
  • Declare belongs_to :user association on SetupSurveyResponse to complement User.has_one :setup_survey_response
app/models/setup_survey_response.rb

Possibly linked issues

  • #[BUG] Login fails with 500 on latest: Missing model class SetupSurveyResponse: Issue reports NameError from missing SetupSurveyResponse; PR adds the missing model file to fix it.
  • #[BUG] evo-auth-service-community:latest - Login fails with NameError: Missing model class SetupSurveyResponse: PR adds SetupSurveyResponse model required by User association, directly fixing the login NameError from issue.

Tips and commands

Interacting with Sourcery

  • Trigger a new review: Comment @sourcery-ai review on the pull request.
  • Continue discussions: Reply directly to Sourcery's review comments.
  • Generate a GitHub issue from a review comment: Ask Sourcery to create an
    issue from a review comment by replying to it. You can also reply to a
    review comment with @sourcery-ai issue to create an issue from it.
  • Generate a pull request title: Write @sourcery-ai anywhere in the pull
    request title to generate a title at any time. You can also comment
    @sourcery-ai title on the pull request to (re-)generate the title at any time.
  • Generate a pull request summary: Write @sourcery-ai summary anywhere in
    the pull request body to generate a PR summary at any time exactly where you
    want it. You can also comment @sourcery-ai summary on the pull request to
    (re-)generate the summary at any time.
  • Generate reviewer's guide: Comment @sourcery-ai guide on the pull
    request to (re-)generate the reviewer's guide at any time.
  • Resolve all Sourcery comments: Comment @sourcery-ai resolve on the
    pull request to resolve all Sourcery comments. Useful if you've already
    addressed all the comments and don't want to see them anymore.
  • Dismiss all Sourcery reviews: Comment @sourcery-ai dismiss on the pull
    request to dismiss all existing Sourcery reviews. Especially useful if you
    want to start fresh with a new review - don't forget to comment
    @sourcery-ai review to trigger a new review!

Customizing Your Experience

Access your dashboard to:

  • Enable or disable review features such as the Sourcery-generated pull request
    summary, the reviewer's guide, and others.
  • Change the review language.
  • Add, remove or edit custom review instructions.
  • Adjust other review settings.

Getting Help

Copy link
Copy Markdown

@sourcery-ai sourcery-ai Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hey - I've reviewed your changes and they look great!


Sourcery is free for open source - if you like our reviews please consider sharing them ✨
Help me be more useful! Please click 👍 or 👎 on each comment and I'll use the feedback to improve your reviews.

…tion failure

users_controller#create now rescues ActiveRecord::RecordInvalid and returns
a 422 with structured error messages (password complexity rules).
Previously bubbled up as unhandled 500.
@pastoriniMatheus pastoriniMatheus changed the base branch from main to develop May 13, 2026 17:44
@dpaes
Copy link
Copy Markdown
Contributor

dpaes commented May 13, 2026

@

🚧 Pedido de split antes da review — escopo divergente

Olá @pastoriniMatheus, este PR carrega três entregas não relacionadas que precisam ser separadas antes da review substantiva. O título do PR cita só o hotfix do SetupSurveyResponse, mas o diff inclui escopos não mencionados no título nem no body.

Conteúdo atual do PR (195+/18- em 15 arquivos)

Origem Arquivos Linhas
EVO-1063 (card In Review) app/controllers/api/v1/users_controller.rb +7
EVO-976 (avatar URL absoluto) avatarable.rb, profiles_controller.rb, environment_config.rb, development.rb, cors.rb ~70
Hotfix SetupSurveyResponse missing setup_survey_response.rb (novo), user.rb, serializers/*, setup_controller.rb, setup_bootstrap_service.rb, routes.rb ~110

O headRefName (fix/evolution-go-api-integration-issues) também não corresponde a nenhum dos três escopos.

Por que isso bloqueia review

  • Não dá para mergear só o EVO-1063 sem levar EVO-976 e o hotfix junto.
  • Rollback granular fica inviável.
  • Reviewer perde a granularidade de aprovar/recusar por card.

Pedido

Separar em 3 branches/PRs:

  1. fix/EVO-1063 — apenas users_controller.rb (+7). Base develop. Título fix(EVO-1063): return structured 422 on user creation password validation failure.
  2. fix/EVO-976 — entrega de avatar URL absoluto + AUTH_SERVICE_URL config.
  3. hotfix/setup-survey-response-model — model + association + routes + serializer + bootstrap (causava NameError no login).

Mais detalhes e raciocínio completo no card Linear EVO-1063. Voltando o card para Todo até a separação.
@

@pastoriniMatheus
Copy link
Copy Markdown
Author

PR #22 fechada — splitada em 3 PRs dedicadas

Esta PR misturava 3 escopos não relacionados em uma única branch, conforme apontado pelo Daniel no code review. Foi dividida em:

PR Escopo Status
#23 EVO-1063 — password 422 structured errors ✅ Mergeada (14/05)
#27 Hotfix SetupSurveyResponse (NameError login) 🆕 Aberta → develop
#28 EVO-976 — avatar URL absoluto + CORS/S3 🆕 Aberta → develop

Cada PR agora tem escopo limpo, 1 commit, título correto e base develop.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants