Skip to content

[OP-19968] Fix 500 when writing end_time on a time entry - #24775

Open
jtauschl wants to merge 2 commits into
opf:devfrom
jtauschl:fix/time-entries-end-time-write-crash
Open

[OP-19968] Fix 500 when writing end_time on a time entry#24775
jtauschl wants to merge 2 commits into
opf:devfrom
jtauschl:fix/time-entries-end-time-write-crash

Conversation

@jtauschl

@jtauschl jtauschl commented Aug 14, 2026

Copy link
Copy Markdown

Ticket

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

Summary

end_time is derived (start_time + hours) and has no setter of its own -- the date_time_property declaration had a custom getter but no setter, so Representable fell through to its default send(:end_time=, value) when a client included endTime in a write payload, crashing with NoMethodError since TimeEntry defines no such method.

Change

Add an explicit no-op setter, matching how other purely-computed read-only representer properties in this codebase already handle a write attempt.

Test plan

  • Added a regression parsing spec asserting no error is raised when endTime is included in a write payload
  • Verified live against a real 17.7.1 instance (with "Allow start and finish times" enabled): before the fix, POST with endTime set → 500; after the fix → 201, entry created successfully

end_time is derived (start_time + hours) and has no setter of its own
-- the date_time_property declaration had a custom getter but no
setter, so Representable fell through to its default
send(:end_time=, value) when a client included endTime in a write
payload, crashing with NoMethodError since TimeEntry defines no such
method.

Add an explicit no-op setter, matching how other purely-computed
read-only representer properties in this codebase already handle a
write attempt.
@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 changed the title Fix 500 when writing end_time on a time entry [OP-19968] Fix 500 when writing end_time on a time entry Aug 15, 2026
@myabc
myabc requested a lite review from Copilot August 15, 2026 18:33

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

Fixes a crash in the Costs module’s API v3 time entry representer when clients include endTime in write payloads, by explicitly handling the field as unwritable (since end_time is derived from start_time + hours and has no model setter).

Changes:

  • Add an explicit no-op setter for the computed end_time representer property to prevent Representable from calling a non-existent end_time= method.
  • Add a regression parsing spec ensuring payloads containing endTime no longer raise (and should be ignored).

Reviewed changes

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

File Description
modules/costs/lib/api/v3/time_entries/time_entry_representer.rb Adds a no-op setter for computed end_time to avoid NoMethodError on write payloads containing endTime.
modules/costs/spec/lib/api/v3/time_entries/time_entry_representer_parsing_spec.rb Adds a regression spec for parsing write payloads that include endTime.

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

Comment thread modules/costs/spec/lib/api/v3/time_entries/time_entry_representer_parsing_spec.rb Outdated
Comment on lines +126 to +130
setter: ->(*) {
# end_time is derived (start_time + hours), never its own column --
# silently accept a write attempt without touching the record, same
# as any other purely-computed read-only API property.
},
Collapse the setter to a one-line no-op matching this codebase's existing
convention for an ignored representer property (setter: ->(*) {} #
ignored, per query_representer.rb's :hidden property). The regression
spec's respond_to?(:end_time=) assertion was always true/false
independent of whether the payload was actually respected -- TimeEntry
never had that method regardless of the fix. Replaced with an assertion
that a deliberately different endTime value is genuinely ignored,
verified against the value start_time + hours actually derives.
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