Self-hosted project management for devs and their clients: tickets, time tracking, docs and meetings, with an AI assistant that cites its sources. AGPL-3.0.
Ruby agplai-assistantdockerdsgvogdprhotwireissue-trackerjira-alternativeknowledge-basellmmcp-servermeeting-notesopen-sourceproject-managementredmine-alternativeruby-on-railsself-hostedticketingtime-tracking
Fix review round 1 of #85: name what Rails does first, pin two gaps
Guido Boyke2b1fb5e67511
diff --git a/CLAUDE.md b/CLAUDE.mdindex e891089..7ed844a 100644--- a/CLAUDE.md+++ b/CLAUDE.md@@ -924,11 +924,14 @@ go through `Actors::ApplyTicketChanges` like a board drag (a `TicketBulkRun` incthrough `Actors::SaveTicket` alone under a lock on the row in its project, so the side effects arethe web's and MCP's, once. Order: read-only token 403, then the read gate (missing, malformed,foreign, out of reach, hidden: one 404, whatever the body), then `authorize :update?` (403, whatever-the body), and only then the input, so a refusal of it only ever answers a caller who may write.+the body), and only then the input, so a refusal of it only ever answers a caller who may write. A+body Rails cannot read comes before the gate: a 400, the same for every ticket.Input refused (mixed kinds, an unknown key, no `change`, the title rule, a list that is no list,over 50, the same person in both lists, text that is no UTF-8): 422`validation_failed`/`invalid_input`, a text from `services.ticket_change.*` that repeats nothing the-client sent. Stopped by the project's state: 422 with `code: refused`, and `error` and `reason` the+client sent. One difference to MCP is Rails', not the rule's: a JSON `null` in a list is gone before+the rule reads it, so `[id, null]` is `[id]` here and refused there; it names nobody either way.+Stopped by the project's state: 422 with `code: refused`, and `error` and `reason` thesame word (`value_not_allowed`, `user_not_assignable`, `no_status_field`, `validation_failed`), atext from `services.ticket_change_failure.*` in `errors` and, for a title the model refuses, itsmessages behind it. The code is named in the controller: `Api::V1::ErrorBody` alone would readdiff --git a/app/controllers/api/v1/tickets_controller.rb b/app/controllers/api/v1/tickets_controller.rbindex 0b38abf..501dc50 100644--- a/app/controllers/api/v1/tickets_controller.rb+++ b/app/controllers/api/v1/tickets_controller.rb@@ -123,6 +123,7 @@ module Api# Missing, foreign and unreadable tickets answer the same 404 whatever the# input, a ticket the token may not write the same 403: the input is read# after both, so a refusal of it only ever answers a caller who may write.+ # Only a body Rails cannot read comes first, a 400 for every ticket alike.def changeswith_readable_ticket(params[:id]) do |ticket, project|authorize ticket, :update?@@ -255,7 +256,9 @@ module Api# The keys and values as they came: strong parameters would drop a list# where a text belongs and a key nobody permitted, and the rule refuses- # both. A change that is no object is none at all.+ # both. A change that is no object is none at all. As they came, up to+ # Rails, which drops a JSON null from a list on the way into params: it+ # names nobody, so nobody is added or removed for it.def change_inputinput = params[:change]input.is_a?(ActionController::Parameters) ? input.to_unsafe_h : {}diff --git a/spec/requests/api/v1/ticket_changes_spec.rb b/spec/requests/api/v1/ticket_changes_spec.rbindex ec0074d..4de51dd 100644--- a/spec/requests/api/v1/ticket_changes_spec.rb+++ b/spec/requests/api/v1/ticket_changes_spec.rb@@ -303,12 +303,29 @@ RSpec.describe 'API V1 ticket changes', :ci_guard, type: :request doendend- # Rails drops a JSON null from a list before the rule sees it: it names nobody.+ # Rails drops a JSON null from a list before the rule sees it: it names+ # nobody. MCP gets the list as sent and refuses it.it 'reads a list of nulls as naming nobody' dosend_change({ add_assignee_ids: [nil] })expect_invalid_input('Name at least one user in add_assignee_ids or remove_assignee_ids.')end+ it 'reads a null beside a person as nobody, and adds the person it names' do+ assign(colleague)+ send_change({ add_assignee_ids: [user.id, nil] })++ expect(response).to have_http_status(:ok)+ expect(assignee_ids).to contain_exactly(user.id, colleague.id)+ end++ it 'takes nobody off for a null, only the person it names' do+ assign(colleague, user)+ send_change({ add_assignee_ids: [nil], remove_assignee_ids: [colleague.id] })++ expect(response).to have_http_status(:ok)+ expect(assignee_ids).to eq([user.id])+ end+it 'refuses a person the project does not offer loudly, and takes nobody off' doassign(colleague)before = writtendiff --git a/spec/services/tickets/change_spec.rb b/spec/services/tickets/change_spec.rbindex 8f309bd..8cb2867 100644--- a/spec/services/tickets/change_spec.rb+++ b/spec/services/tickets/change_spec.rb@@ -368,6 +368,14 @@ RSpec.describe Tickets::Change, :ci_guard docustom_attributes: { 'status' => 'open', 'priority' => 'high', 'area' => 'backend' })end+ # String#strip knows only ASCII.+ it 'stores the title without the spaces of any kind at its edges' do+ title = "#{0xA0.chr(Encoding::UTF_8)}Neu#{0x3000.chr(Encoding::UTF_8)}"++ expect(write({ title: title })).to be_written+ expect(ticket.reload.title).to eq('Neu')+ end+it 'names the caller in the history, also without an ambient Current.user' doCurrent.reset