Skip to content

Upgrade Ruby to 3.1.7 - #1337

Open
warp wants to merge 13 commits into
masterfrom
upgrade/ruby-3.1.7
Open

Upgrade Ruby to 3.1.7#1337
warp wants to merge 13 commits into
masterfrom
upgrade/ruby-3.1.7

Conversation

@warp

@warp warp commented May 5, 2026

Copy link
Copy Markdown
Contributor

Updates version pins across Docker, CircleCI, and deploy scripts, and enables YAML alias loading where Psych now requires it.

Summary by CodeRabbit

  • Chores

    • Upgraded Ruby to 3.1.7 across CI, Docker, deploy and runtime; updated Bundler to 2.3.27 and simplified CI test setup (Postgres client install).
    • Regenerated DB schema (timestamp/index normalization).
    • Enabled YAML alias support when loading fixtures/seeds.
    • Set explicit API port and updated Sidekiq runtime/service.
  • Refactor

    • Improved argument handling across services, token generation, builders and factories; deterministic ordering added to a paginated endpoint; removed an initializer patch.

Updates version pins across Docker, CircleCI, and deploy scripts, and enables YAML alias loading where Psych now requires it.
@coderabbitai

coderabbitai Bot commented May 5, 2026

Copy link
Copy Markdown

Note

Reviews paused

It looks like this branch is under active development. To avoid overwhelming you with review comments due to an influx of new commits, CodeRabbit has automatically paused this review. You can configure this behavior by changing the reviews.auto_review.auto_pause_after_reviewed_commits setting.

Use the following commands to manage reviews:

  • @coderabbitai resume to resume automatic reviews.
  • @coderabbitai review to trigger a single review.

Use the checkboxes below for quick actions:

  • ▶️ Resume reviews
  • 🔍 Trigger review

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: dc3b5ca2-e109-477a-a60e-8a543b1f663f

📥 Commits

Reviewing files that changed from the base of the PR and between f7f2b63 and d767df5.

📒 Files selected for processing (1)
  • spec/controllers/api/v1/packages_controller_spec.rb

📝 Walkthrough

Walkthrough

Upgrades Ruby from 2.7.3 → 3.1.7 across CI, Docker, deploy, systemd and scripts; standardizes Bundler to 2.3.27 in CircleCI; regenerates db/schema.rb (timestamp precision/nullability changes); enables YAML alias support for permissions/roles loading; sets PORT in the Procfile; plus assorted API/factory/test callsite adjustments.

Changes

Ruby & Bundler upgrade

Layer / File(s) Summary
Environment Pinning
.ruby-version, Gemfile, Dockerfile
Pinned Ruby 2.7.33.1.7; Docker base image updated to ruby:3.1.7-alpine; Gemfile ruby requirement updated.
CI Images & Bundler
.circleci/config.yml
CircleCI default and test images updated to cimg/ruby:3.1.7*; Bundler install commands updated 2.2.272.3.27; test job simplifies PostgreSQL client install to postgresql-client.
Deployment & Runtime
config/deploy.rb, config/systemd/sidekiq-production.service, script/sidekiq_stats.rb
RVM/Ruby version set to 3.1.7 in deploy and systemd unit; sidekiq_stats shebang updated to ruby-3.1.7.
Container runtime / Procfile
Procfile
api process now includes --port ${PORT:-3000} for explicit port binding.

YAML alias support for permissions/roles

Layer / File(s) Summary
YAML Loaders
db/seeds.rb, lib/classes/role_permissions_mappings.rb, spec/factories/roles.rb, spec/factories/sequences.rb
Loaders for db/permissions_roles.yml now call YAML.load_file(..., aliases: true) to enable YAML alias/anchor support.
Specs / Fixtures
spec/factories/donor_conditions.rb
Factory transient seq uses YAML.unsafe_load_file(path) when available, else falls back to YAML.load_file(path) to support newer Psych/YAML tag behavior.

Schema regeneration & miscellaneous behavior changes

Layer / File(s) Summary
Schema Regeneration
db/schema.rb
Regenerated schema: explicit precision: 6 removed from many timestamp columns; some created_at/updated_at nullability differences; messages composite index renamed to index_messages_on_messageable_and_created_at preserving created_at: :desc.
StateMachine initializer removed
config/initializers/state_machine_patch.rb
Removed initializer that previously made around_validation/around_save public on StateMachine integrations.
API / Callsite adjustments
app/models/concerns/operations/stock_operations.rb, app/services/twilio_service.rb, app/models/token.rb, lib/goodcity/errors.rb
Argument/parameter handling changes: register_quantity_change forwards via **params; TwilioService#send_sms accepts options = nil, **kwargs and merges before enqueueing; Token#generate and helpers default params = {} and accept **extra_params; I18n call in errors uses **params.
Migration guard tweak
db/migrate/20251219000001_add_index_to_messages_on_messageable_and_created_at.rb
index_exists? check updated to include explicit nil column argument when checking by name.
Tests / Factory updates
spec/controllers/*, spec/factories/*, spec/lib/*, spec/rails_helper.rb
Multiple spec updates: controller calls use params: shorthand; FactoryBot calls qualified; factory creation patterns adjusted; Timecop freeze updated; conditional system-user creation; YAML loader changes in specs.

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~28 minutes

Poem

🐰 Bundler hops to two-point-three,
Ruby bounds to three-one-seven with glee.
YAML aliases now nest and play,
Timestamps trimmed at break of day.
PORT set—carrots for deploys, whee! 🥕

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 45.45% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title 'Upgrade Ruby to 3.1.7' clearly and directly summarizes the primary change: updating the Ruby version from 2.7.3 to 3.1.7 across all relevant configuration files, Docker images, and deployment settings.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch upgrade/ruby-3.1.7

Tip

💬 Introducing Slack Agent: The best way for teams to turn conversations into code.

Slack Agent is built on CodeRabbit's deep understanding of your code, so your team can collaborate across the entire SDLC without losing context.

  • Generate code and open pull requests
  • Plan features and break down work
  • Investigate incidents and troubleshoot customer tickets together
  • Automate recurring tasks and respond to alerts with triggers
  • Summarize progress and report instantly

Built for teams:

  • Shared memory across your entire org—no repeating context
  • Per-thread sandboxes to safely plan and execute work
  • Governance built-in—scoped access, auditability, and budget controls

One agent for your entire SDLC. Right inside Slack.

👉 Get started


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.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Actionable comments posted: 2

🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In `@Procfile`:
- Line 2: The Procfile entry currently hardcodes PORT=3000 which overrides
injected ports; update the proc command that starts the Rails server (the "api:
PORT=3000 bundle exec rails server --binding=0.0.0.0" line) to respect
environment-provided PORT by using a shell fallback (e.g., use ${PORT:-3000}) or
simply remove the explicit assignment so the process uses the existing PORT env
var, ensuring the rails server still binds to 0.0.0.0.

In `@spec/factories/roles.rb`:
- Around line 40-41: The role factory is breaking because YAML aliases produce
nested arrays; in the block iterating YAML.load_file(...).each do |role_name,
permissions|, flatten the permissions (e.g., call permissions =
permissions.flatten) before the inner permissions.each so trait names aren't
built from arrays and the create(:permission, name: permission) call receives a
string; also defensively coerce permission to a string (permission.to_s) when
building trait identifiers and when passing to create to avoid non-string
values.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: 074f9187-44e4-4fac-ae7d-35a76cc9d36e

📥 Commits

Reviewing files that changed from the base of the PR and between 94a82c5 and 71b72a4.

⛔ Files ignored due to path filters (1)
  • Gemfile.lock is excluded by !**/*.lock
📒 Files selected for processing (13)
  • .circleci/config.yml
  • .ruby-version
  • Dockerfile
  • Gemfile
  • Procfile
  • config/deploy.rb
  • config/systemd/sidekiq-production.service
  • db/schema.rb
  • db/seeds.rb
  • lib/classes/role_permissions_mappings.rb
  • script/sidekiq_stats.rb
  • spec/factories/roles.rb
  • spec/factories/sequences.rb

Comment thread Procfile Outdated
Comment thread spec/factories/roles.rb
warp added 2 commits May 5, 2026 20:55
Stop using apt-archive.postgresql.org (no Jammy Release file) and install postgresql-client from Ubuntu packages so apt update succeeds.
Use the ActiveRecord migration compatibility signature (2 positional args + keyword options) to avoid Ruby 3 keyword-arg arity errors.
@warp
warp force-pushed the upgrade/ruby-3.1.7 branch from 3b58820 to e3d46e0 Compare May 5, 2026 09:09
warp added 2 commits May 5, 2026 21:17
Load donor conditions YAML in a Psych 4 compatible way and call I18n.t with keyword args to avoid Ruby 3 arity failures.
Replace the unmaintained state_machine gem with state_machines-activerecord and remove the legacy initializer patch. Also fix Ruby 3 keyword-arg and factory issues uncovered during the migration.
@guardrails

guardrails Bot commented May 5, 2026

Copy link
Copy Markdown

⚠️ We detected 1 security issue in this pull request:

Vulnerable Libraries (1)
Severity Details
High pkg:gem/state_machines-activerecord@0.9.0 upgrade to: > 0.9.0

More info on how to fix Vulnerable Libraries in Ruby.


👉 Go to the dashboard for detailed results.

📥 Happy? Share your feedback with us.

Enqueue Twilio jobs with keyword args while remaining compatible with callers
passing an options hash, and update package controller specs to use keyword
params for Rails.

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

🧹 Nitpick comments (1)
lib/goodcity/errors.rb (1)

79-80: ⚡ Quick win

Consider hardening params argument to accept both string and symbol keys.

The **params pattern requires all keys to be symbols. While the current codebase only passes the default empty hash (safe), a defensive check could protect against future misuse if callers pass params: {'string_key' => 'value'}, which would raise at runtime. The suggested fix adds to_h.symbolize_keys to normalize the hash regardless of key type.

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@lib/goodcity/errors.rb` around lines 79 - 80, The initializer defined by
define_method(:initialize) currently splats params with **params which fails if
callers pass string-keyed hashes; update the initialize block to coerce params
into a hash with symbolized keys (e.g., ensure params =
params.to_h.symbolize_keys || {} before calling I18n.t) so both string and
symbol keys are accepted and then pass the normalized params into I18n.t; adjust
the reference in this initialize method accordingly.
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Nitpick comments:
In `@lib/goodcity/errors.rb`:
- Around line 79-80: The initializer defined by define_method(:initialize)
currently splats params with **params which fails if callers pass string-keyed
hashes; update the initialize block to coerce params into a hash with symbolized
keys (e.g., ensure params = params.to_h.symbolize_keys || {} before calling
I18n.t) so both string and symbol keys are accepted and then pass the normalized
params into I18n.t; adjust the reference in this initialize method accordingly.

ℹ️ Review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: 130086ce-2d1e-47dd-88db-4fe5fe837c7e

📥 Commits

Reviewing files that changed from the base of the PR and between 71b72a4 and cf3610e.

⛔ Files ignored due to path filters (1)
  • Gemfile.lock is excluded by !**/*.lock
📒 Files selected for processing (11)
  • .circleci/config.yml
  • Gemfile
  • app/models/concerns/operations/stock_operations.rb
  • app/services/twilio_service.rb
  • config/initializers/state_machine_patch.rb
  • db/migrate/20251219000001_add_index_to_messages_on_messageable_and_created_at.rb
  • lib/goodcity/errors.rb
  • spec/controllers/api/v1/packages_controller_spec.rb
  • spec/factories/donor_conditions.rb
  • spec/factories/offers.rb
  • spec/factories/orders.rb
💤 Files with no reviewable changes (1)
  • config/initializers/state_machine_patch.rb
✅ Files skipped from review due to trivial changes (2)
  • spec/factories/offers.rb
  • spec/controllers/api/v1/packages_controller_spec.rb
🚧 Files skipped from review as they are similar to previous changes (2)
  • Gemfile
  • .circleci/config.yml

warp added 3 commits May 5, 2026 22:01
Allow Token generation helpers and OrganisationsUserBuilder to accept either a
hash or keyword args, and update requested packages controller specs to use
Rails keyword params.
Avoid asserting a specific order for shareable offers when including expired
shareables; the query does not guarantee ordering.
Make user filtering handle symbol/string param keys, stabilize holidays available
_dates spec by freezing time, and stub appstore reviewer login number in safe
delete specs.

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Actionable comments posted: 1

Caution

Some comments are outside the diff and can’t be posted inline due to platform limitations.

⚠️ Outside diff range comments (1)
spec/controllers/api/v1/holidays_controller_spec.rb (1)

23-28: ⚠️ Potential issue | 🟡 Minor | ⚡ Quick win

The to_not include(holiday_1) assertion on line 27 is vacuously true.

holiday_1 is created at Time.zone.now + 30.days, but the request asks for schedule_days: 6, start_from: 2, which returns at most 6 working days starting 2 days from now (a window of ~8 calendar days). A holiday 30 days out can never appear in that window, so this expect(body).to_not include(...) will always pass regardless of whether the controller correctly filters holidays.

To make this a meaningful assertion, create the holiday within the requested window (e.g. + 3.days) and assert it is excluded:

🔧 Proposed fix
+  let!(:holiday_in_range) { create(:holiday, holiday: Time.zone.now + 3.days) }
+
   it "return serialized available_dates within given range", :show_in_doc do
     get :available_dates, params: { schedule_days: 6, start_from: 2 }
     body = JSON.parse(response.body)
     expect(body.length).to eq(6)
-    expect(body).to_not include(JSON.parse(holiday_1.holiday.to_json))
+    expect(body).to_not include(JSON.parse(holiday_in_range.holiday.to_json))
   end
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@spec/controllers/api/v1/holidays_controller_spec.rb` around lines 23 - 28,
The test's negative assertion is vacuous because holiday_1 is created at
Time.zone.now + 30.days and will never fall in the requested window; update the
setup so holiday_1 is created inside the window (e.g., change its timestamp to
Time.zone.now + 3.days or similar) and then assert the response body does not
include JSON.parse(holiday_1.holiday.to_json) (keeping the existing
expect(body).to_not include(...) assertion) so the expectation actually verifies
filtering logic for the available_dates action.
🧹 Nitpick comments (2)
spec/controllers/api/v1/holidays_controller_spec.rb (1)

32-38: 💤 Low value

Hardcoded freeze date 2026-05-05 will silently lose its intent over time.

Pinning Timecop.freeze to an absolute calendar date is fragile: if the test is re-read or copied months/years later the date has no self-evident meaning, and if the underlying available_dates logic ever becomes sensitive to day-of-week or locale-specific holidays, the Tuesday-specific choice won't be obvious. Consider computing relative to an arbitrary reference or documenting the day-of-week requirement inline.

-        Timecop.freeze(Time.zone.local(2026, 5, 5, 12, 0, 0)) do
+        # Freeze to a known Tuesday mid-day so the frozen day is a weekday
+        Timecop.freeze(Time.zone.local(2026, 5, 5, 12, 0, 0)) do

At minimum, a brief comment explains why this date was chosen.

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@spec/controllers/api/v1/holidays_controller_spec.rb` around lines 32 - 38,
The test currently hardcodes Timecop.freeze(Time.zone.local(2026, 5, 5, 12, 0,
0)); replace that literal with a named reference (e.g. reference_date) computed
to satisfy the test's day-of-week requirement (for example: pick a Date/Time
that is explicitly a Tuesday) and use Timecop.freeze(reference_date) and
create(:holiday, holiday: reference_date.beginning_of_day) and get
:available_dates, params: { schedule_days: 6 } so the intent is clear and
robust; if you keep a fixed date instead, add a one-line comment next to
Timecop.freeze explaining why that specific date/day-of-week was chosen
(referencing Timecop.freeze, create(:holiday, ...) and get :available_dates).
app/models/token.rb (1)

45-45: 💤 Low value

(params || {}) guard is redundant

params already defaults to {} on line 41, so the || {} branch is never reached.

♻️ Proposed simplification
-    params = (params || {}).merge(extra_params)
+    params = params.merge(extra_params)
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@app/models/token.rb` at line 45, The `(params || {})` guard is redundant
because `params` is already defaulted to `{}` earlier; replace `params = (params
|| {}).merge(extra_params)` with a direct merge using `params` (i.e., `params =
params.merge(extra_params)`), referencing the `params` and `extra_params`
variables in token.rb so the code is simplified and clearer.
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In `@app/models/user.rb`:
- Around line 178-181: The local variable res can be nil when search_text is
blank causing NoMethodError on later chained scope calls; to fix, initialize res
to a base scope (e.g., User.all or self) before applying conditionals, then call
the existing methods search(search_text),
with_organisation_status(organisation_status.split(',')) and
with_roles(role_name) only to narrow that base scope; update the block that
currently assigns to res to start with res = all (or self) and then apply the
three conditional assignments using the existing methods search,
with_organisation_status, and with_roles so the method always returns an
ActiveRecord::Relation instead of nil.

---

Outside diff comments:
In `@spec/controllers/api/v1/holidays_controller_spec.rb`:
- Around line 23-28: The test's negative assertion is vacuous because holiday_1
is created at Time.zone.now + 30.days and will never fall in the requested
window; update the setup so holiday_1 is created inside the window (e.g., change
its timestamp to Time.zone.now + 3.days or similar) and then assert the response
body does not include JSON.parse(holiday_1.holiday.to_json) (keeping the
existing expect(body).to_not include(...) assertion) so the expectation actually
verifies filtering logic for the available_dates action.

---

Nitpick comments:
In `@app/models/token.rb`:
- Line 45: The `(params || {})` guard is redundant because `params` is already
defaulted to `{}` earlier; replace `params = (params || {}).merge(extra_params)`
with a direct merge using `params` (i.e., `params =
params.merge(extra_params)`), referencing the `params` and `extra_params`
variables in token.rb so the code is simplified and clearer.

In `@spec/controllers/api/v1/holidays_controller_spec.rb`:
- Around line 32-38: The test currently hardcodes
Timecop.freeze(Time.zone.local(2026, 5, 5, 12, 0, 0)); replace that literal with
a named reference (e.g. reference_date) computed to satisfy the test's
day-of-week requirement (for example: pick a Date/Time that is explicitly a
Tuesday) and use Timecop.freeze(reference_date) and create(:holiday, holiday:
reference_date.beginning_of_day) and get :available_dates, params: {
schedule_days: 6 } so the intent is clear and robust; if you keep a fixed date
instead, add a one-line comment next to Timecop.freeze explaining why that
specific date/day-of-week was chosen (referencing Timecop.freeze,
create(:holiday, ...) and get :available_dates).
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: 25b084e4-9a38-4960-9bd0-01c20f526ecc

📥 Commits

Reviewing files that changed from the base of the PR and between cf3610e and 7461bbc.

📒 Files selected for processing (7)
  • app/models/token.rb
  • app/models/user.rb
  • lib/classes/organisations_user_builder.rb
  • spec/controllers/api/v1/holidays_controller_spec.rb
  • spec/controllers/api/v1/offers_controller_spec.rb
  • spec/controllers/api/v1/requested_packages_controller_spec.rb
  • spec/lib/goodcity/user_safe_delete_spec.rb

Comment thread app/models/user.rb Outdated
Flatten YAML-derived permissions in role factory, tighten role filtering to
active roles, make the system user setup idempotent, avoid rspec-mocks stubbing
outside the lifecycle, and respect injected PORT in Procfile.
@warp

warp commented May 5, 2026

Copy link
Copy Markdown
Contributor Author

@steveyken The only outstanding issue I know of is that state_machines-activerecord ~> 0.9.0 has a high vulnerability. I can't seem to find details, but it appears we would need to upgrade Rails to move to a patched version.

@warp
warp requested a review from steveyken May 5, 2026 11:23
warp and others added 2 commits May 5, 2026 23:34
Co-authored-by: coderabbitai[bot] <136622811+coderabbitai[bot]@users.noreply.github.com>
Order shareables by id before paginating to ensure stable page boundaries, and
update the message subscriptions concern spec to reference the correct module
and avoid building unrelated records.

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Caution

Some comments are outside the diff and can’t be posted inline due to platform limitations.

⚠️ Outside diff range comments (1)
app/controllers/api/v2/shareables_controller.rb (1)

127-132: ⚠️ Potential issue | 🟡 Minor | ⚡ Quick win

Apply filters before paginate to ensure pagination operates on the filtered scope

The current code paginates the full @shareables collection (line 127), then applies .of_type and .where(resource_id:) filters afterward (lines 128–129). This means paginate divides the unfiltered set into pages, and then the filters remove items from those pages—potentially leaving you with far fewer results per page than intended and breaking pagination semantics.

Apply the filters to @shareables before calling paginate:

♻️ Proposed fix
-      # Ensure stable pagination order
-      records = paginate(`@shareables.order`(id: :asc))
-      records = records.of_type(params[:resource_type])                      if params[:resource_type].present?
-      records = records.where(resource_id: params[:resource_id].split(','))  if params[:resource_id].present?
+      # Apply filters first so pagination operates on the filtered scope
+      shareables = `@shareables`
+      shareables = shareables.of_type(params[:resource_type])                      if params[:resource_type].present?
+      shareables = shareables.where(resource_id: params[:resource_id].split(','))  if params[:resource_id].present?
+      records = paginate(shareables.order(id: :asc))
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@app/controllers/api/v2/shareables_controller.rb` around lines 127 - 132, The
code calls paginate on `@shareables` before applying filters, which breaks
pagination semantics; update the flow to apply filters (use .of_type when
params[:resource_type].present? and .where(resource_id:
params[:resource_id].split(',')) when params[:resource_id].present?) to the
`@shareables` scope first, then call paginate(...) on that filtered scope, and
finally pass the paginated records into serialize_shareables with the existing
pagination_meta.
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Outside diff comments:
In `@app/controllers/api/v2/shareables_controller.rb`:
- Around line 127-132: The code calls paginate on `@shareables` before applying
filters, which breaks pagination semantics; update the flow to apply filters
(use .of_type when params[:resource_type].present? and .where(resource_id:
params[:resource_id].split(',')) when params[:resource_id].present?) to the
`@shareables` scope first, then call paginate(...) on that filtered scope, and
finally pass the paginated records into serialize_shareables with the existing
pagination_meta.

ℹ️ Review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: 56cd9989-c612-4910-abd3-aea6e87a591e

📥 Commits

Reviewing files that changed from the base of the PR and between 7461bbc and f7f2b63.

📒 Files selected for processing (7)
  • Procfile
  • app/controllers/api/v2/shareables_controller.rb
  • app/models/user.rb
  • spec/factories/roles.rb
  • spec/lib/goodcity/user_safe_delete_spec.rb
  • spec/models/concerns/message_subscriptions_spec.rb
  • spec/rails_helper.rb
🚧 Files skipped from review as they are similar to previous changes (4)
  • Procfile
  • app/models/user.rb
  • spec/factories/roles.rb
  • spec/lib/goodcity/user_safe_delete_spec.rb

Avoid flaky failures when other published packages match the generic
substring "towel" in notes or related search fields.
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.

1 participant