Skip to content

[OP-19964] Fix 500 when creating a meeting outcome with an invalid kind - #24771

Open
jtauschl wants to merge 2 commits into
opf:devfrom
jtauschl:fix/meeting-outcome-invalid-kind-crashes
Open

[OP-19964] Fix 500 when creating a meeting outcome with an invalid kind#24771
jtauschl wants to merge 2 commits into
opf:devfrom
jtauschl:fix/meeting-outcome-invalid-kind-crashes

Conversation

@jtauschl

@jtauschl jtauschl commented Aug 14, 2026

Copy link
Copy Markdown

Ticket

https://community.openproject.org/wp/OP-19964

Summary

MeetingOutcome's kind enum was declared without validate: true, so assigning an unrecognized value raised a raw Rails ArgumentError instead of a normal ActiveModel validation error, propagating uncaught through the API endpoint as a 500.

Change

Add validate: true to the enum declaration -- Rails then rejects an out-of-enum value through the usual validation path, returning a clean 422.

Test plan

  • Added a regression request spec asserting a 422 (not a 500) for an invalid kind, and that no outcome is created
  • Verified live against a real 17.7.1 instance: before the fix, invalid kind → 500; after the fix → 422 ("Kind is not set to one of the allowed values."); a valid kind still creates successfully

MeetingOutcome's kind enum was declared without validate: true, so
assigning an unrecognized value raised a raw Rails ArgumentError
instead of a normal ActiveModel validation error, propagating uncaught
through the API endpoint as a 500.

Add validate: true to the enum declaration -- Rails then rejects an
out-of-enum value through the usual validation path, returning a clean
422.
@github-actions

github-actions Bot commented Aug 14, 2026

Copy link
Copy Markdown

All contributors have signed the CLA ✍️ ✅
Posted by the CLA Assistant Lite bot.

@jtauschl

Copy link
Copy Markdown
Author

recheck

@myabc
myabc requested a lite review from Copilot August 15, 2026 18:35
@myabc myabc changed the title Fix 500 when creating a meeting outcome with an invalid kind [OP-19964] Fix 500 when creating a meeting outcome with an invalid kind Aug 15, 2026

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Pull request overview

This PR fixes an API 500 when creating a MeetingOutcome with an invalid kind by enabling Rails’ enum validation path, so invalid values produce standard model validation errors (422) instead of raising an ArgumentError.

Changes:

  • Enable enum validation on MeetingOutcome.kind by adding validate: true.
  • Add a request-spec regression case asserting invalid kind yields 422 and does not create an outcome.

Reviewed changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated 1 comment.

File Description
modules/meeting/app/models/meeting_outcome.rb Adds validate: true to the kind enum to turn invalid values into validation errors instead of exceptions.
modules/meeting/spec/requests/api/v3/meeting_outcomes/outcomes_by_agenda_item_resource_spec.rb Adds a regression request spec for invalid kind values, expecting a 422 and no record creation.

💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.

Comment on lines +178 to +181
it "returns 422 rather than raising" do
expect { response }.not_to raise_error
expect(response).to have_http_status(:unprocessable_entity)
end

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

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

RSpec memoizes a named subject/let per example — the block runs at most once per it, with the result cached for subsequent calls within that same example (per RSpec's own documented subject/let behavior). expect { response }.not_to raise_error triggers the actual post path, body and caches it; expect(response) on the next line reuses that cached result. No second request is made. Leaving this as-is.

CI's Units + Features job caught this live: the earlier fix in this PR
(validate: true on the kind enum) means Rails now builds a real
ActiveModel error message on an invalid kind, which needs
human_attribute_name for the attribute -- a key that never existed for
MeetingOutcome. Without it, the 422 path itself crashed with
I18n::MissingTranslationData instead of returning the intended
validation error. Verified live: before this entry, requesting
'activerecord.attributes.meeting_outcome.kind' raised; after, it
resolves to "Kind" and the full validation message reads "Kind is not
set to one of the allowed values."
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Development

Successfully merging this pull request may close these issues.

2 participants