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 2 of #78, a sign in minutes and the MCP failure text
Guido Boyke6777fd228565
diff --git a/CLAUDE.md b/CLAUDE.mdindex 48a309b..1c0565e 100644--- a/CLAUDE.md+++ b/CLAUDE.md@@ -812,10 +812,12 @@ feature by feature):`POST /api/v1/tickets/:ticket_id/time_sessions` books by the rule the MCP tool`create_time_session` books by (REST R6, 2026-10-29; feature `time_sessions.book` in`/me`): `TimeSessions::Booking` refuses no duration, both `duration_string` and-`duration_minutes`, and an `occurred_on` that is no ISO 8601 date or timestamp (422+`duration_minutes`, `duration_minutes` that is no whole number, and an `occurred_on` that is+no ISO 8601 date or timestamp (422`validation_failed`/`invalid_input`, inside the read gate), dates the booking as thecalendar day in the token owner's profile zone (stored as midnight; absent = today there),-and writes through `Actors::SaveTimeSession`. Rights stay in the controller. A booking+and writes through `Actors::SaveTimeSession`; an unexpected actor failure (`internal_error`)+answers 500 without its message. Rights stay in the controller. A bookingwrites no activity and no notification; it touches the ticket's `updated_at`. Guard:`spec/requests/api/v1/time_session_booking_spec.rb`.diff --git a/app/services/lalabase/tools/create_time_session.rb b/app/services/lalabase/tools/create_time_session.rbindex cd002aa..77ddb17 100644--- a/app/services/lalabase/tools/create_time_session.rb+++ b/app/services/lalabase/tools/create_time_session.rb@@ -97,10 +97,20 @@ module Lalabaseauthorize!(context, session, :create?)result = booking.save(session)- return Result.new(error: "booking failed: #{Array(result.errors).join(', ')}") unless result.success?+ return Result.new(error: booking_failure(result)) unless result.success?json_result(TimeSessions::Serializer.row(result.resource))end++ # A refusal of the booking names its reason; an unexpected failure+ # (BaseActor's :internal_error where it does not re-raise) gets a fixed+ # text, its message may name the database.+ def self.booking_failure(result)+ return 'booking failed: unexpected error' if result.code == :internal_error++ "booking failed: #{Array(result.errors).join(', ')}"+ end+ private_class_method :booking_failureendendenddiff --git a/app/services/time_sessions/booking.rb b/app/services/time_sessions/booking.rbindex c1f4cd5..0b6fbfb 100644--- a/app/services/time_sessions/booking.rb+++ b/app/services/time_sessions/booking.rb@@ -28,7 +28,7 @@ module TimeSessionsREFUSALS = %i[duration_missing both_durations duration_minutes_invalid occurred_on_invalid].freezePLAIN_DATE = /\A\d{4}-\d{2}-\d{2}\z/- WHOLE_MINUTES = /\A\s*\d+\s*\z/+ WHOLE_MINUTES = /\A\s*[+-]?\d+\s*\z/attr_reader :refusal@@ -96,10 +96,11 @@ module TimeSessions:occurred_on_invalid if @day.nil?end- # A whole number of minutes, as a number or as digits. A fraction would be- # cut to the minute below ("1.5" booked as 1, while duration_string "1.5"- # is 90 minutes); anything else is no number. Zero and negative numbers pass- # here and are refused by the model (duration > 0).+ # A whole number of minutes, as a number or as digits with an optional+ # sign. A fraction would be cut to the minute below ("1.5" booked as 1,+ # while duration_string "1.5" is 90 minutes); anything else is no number.+ # Zero and negative numbers pass here, in either form, and the model refuses+ # them (duration > 0) with its own message.def whole_minutes?(value)value.is_a?(Integer) || (value.is_a?(String) && value.match?(WHOLE_MINUTES))enddiff --git a/spec/contracts/mcp_contract_recorder.rb b/spec/contracts/mcp_contract_recorder.rbindex a5b9ac1..b6c1254 100644--- a/spec/contracts/mcp_contract_recorder.rb+++ b/spec/contracts/mcp_contract_recorder.rb@@ -504,7 +504,8 @@ module McpContract'idempotency_first' => rest_send(:post, :write, login, params: once, key: key),'idempotency_replay' => rest_send(:post, :write, login, params: once, key: key),'idempotency_mismatch' => rest_send(:post, :write, login, params: { time_session: { duration_string: '0:20' } },- key: key)+ key: key),+ 'invalid_input_minutes' => rest_send(:post, :write, login, params: { time_session: { duration_minutes: '1.5' } })}enddiff --git a/spec/fixtures/mcp_contract.json b/spec/fixtures/mcp_contract.jsonindex d750464..c49b9c5 100644--- a/spec/fixtures/mcp_contract.json+++ b/spec/fixtures/mcp_contract.json@@ -1,9 +1,9 @@{"header": {"regenerate": "RAILS_ENV=test bin/rails mcp:contract",- "core_commit": "5e88fdcd65b8203ec30951a5391789eaf863777c",+ "core_commit": "7a4c067e2cc7810252d636ba7871f7f6d946aa30","core_dirty": true,- "contract_sha256": "ec5e63e1481227b1792970b89b434fb18976a3582fcedd233d8ba2381a7cc088"+ "contract_sha256": "a19edef526822bdabe6699a47c652bea958208ca3b476dfc92e2f45e613077c9"},"contract": {"mcp": {@@ -3947,6 +3947,28 @@"message": "idempotency_key already used with different parameters"}}+ },+ "invalid_input_minutes": {+ "token": "write",+ "request": {+ "method": "POST",+ "path": "/api/v1/tickets/00000000-0000-4000-8000-000000000041/time_sessions",+ "params": {+ "time_session": {+ "duration_minutes": "1.5"+ }+ }+ },+ "response": {+ "status": 422,+ "body": {+ "error": "validation_failed",+ "code": "invalid_input",+ "errors": [+ "Bitte geben Sie duration_minutes als ganze Zahl von Minuten an."+ ]+ }+ }}}}diff --git a/spec/services/lalabase/tools/create_time_session_spec.rb b/spec/services/lalabase/tools/create_time_session_spec.rbindex 10c21d8..90111dc 100644--- a/spec/services/lalabase/tools/create_time_session_spec.rb+++ b/spec/services/lalabase/tools/create_time_session_spec.rb@@ -161,6 +161,14 @@ RSpec.describe Lalabase::Tools::CreateTimeSession doexpect(run(duration_minutes: true).error).to eq('duration_minutes must be a whole number of minutes')end+ # BaseActor answers :internal_error where it does not re-raise (production);+ # its message may name the database, so the agent gets a fixed text.+ it 'answers an unexpected failure without the exception text' do+ allow(Actors::SaveTimeSession).to receive(:call)+ .and_return(Actors::BaseActor::Result.new(success: false, errors: ['PG::Error: secret'], code: :internal_error))+ expect(run(duration: '30').error).to eq('booking failed: unexpected error')+ end+it 'refuses a call without any duration, writing nothing' doresult = nilexpect { result = run({}) }.not_to change(TimeSession, :count)diff --git a/spec/services/time_sessions/booking_spec.rb b/spec/services/time_sessions/booking_spec.rbindex 2c09989..627d720 100644--- a/spec/services/time_sessions/booking_spec.rb+++ b/spec/services/time_sessions/booking_spec.rb@@ -46,7 +46,7 @@ RSpec.describe TimeSessions::Booking doendit 'takes whole minutes as a number or as digits' do- [45, '45', ' 45 ', 0, -5].each do |minutes|+ [45, '45', ' 45 ', '+45', 0, -5, '-5'].each do |minutes|expect(parse(duration_minutes: minutes).refused?).to be(false), minutes.inspectendend