0
0
Fork 0
mirror of https://github.com/discourse/discourse.git synced 2026-08-04 10:39:43 +08:00
discourse/lib/service
Régis Hanol e27a3a4542
DEV: Fill defaulted keyword arguments in service runner blocks (#42264)
Previously, a `Service::Runner` action block could declare a keyword
argument with a default (e.g. `on_success do |table_sizes: {}|`), but
the runner only fills **required** keyword arguments from the service
result — so the default always won and the service's computed value was
silently dropped, producing 200 responses with subtly wrong data (see
#42263 where this happened twice in the workflows plugin).

Following review feedback, instead of raising on defaulted keyword
arguments (the initial approach), the runner now fills them from the
result exactly like required ones. The default only applies when the
service didn't set the key at all, making it a proper fallback for keys
that are only set on some paths — a model fetched by a step that didn't
run, or steps wrapped in an `only_if` block. This matters for outcome
blocks in particular, since the caller (possibly a plugin) doesn't
always own the service it calls and can't make it always set a key.

Also documents required vs defaulted keyword arguments in the service
objects developer guide.
2026-08-03 17:31:37 +02:00
..
base DEV: Preserve existing errors in service model steps (#41896) 2026-07-23 17:15:26 +10:00
action_base.rb DEV: Extract step classes from Service::Base into individual files (#37956) 2026-02-23 09:49:37 +01:00
base.rb DEV: Enable some minor rubocop rules (#40094) 2026-05-19 15:29:38 +02:00
contract_base.rb
nested_contract_type.rb
options_base.rb
policy_base.rb DEV: Extract step classes from Service::Base into individual files (#37956) 2026-02-23 09:49:37 +01:00
runner.rb DEV: Fill defaulted keyword arguments in service runner blocks (#42264) 2026-08-03 17:31:37 +02:00
steps_inspector.rb DEV: Add each step to service framework for collection iteration (#38759) 2026-04-03 09:44:03 +02:00