fix(rl.php): return 422 + errors on fully-rejected batches#48
Merged
Conversation
Why: rl.php used to swallow every rejected decide/turn/reward with a
`continue` and reply 200 `{"ok":true,"decisions":{}}`. The Drupal.rl
client then falls back to `armIds[0]` silently, so a site-wide
misconfiguration (e.g. a new entity-hook that never got its
implementations cache rebuilt, leaving experiments unregistered
despite the container being stamped with a valid-looking eid) is
indistinguishable from a healthy no-op request. The operator has
nothing to grep for in devtools or webserver logs; variants just
appear to never rotate.
handle_batch_request now:
- returns a structured array with `decisions`, `errors`, `requested`,
`succeeded`
- tags each rejected entry with a machine-readable reason
(unknown_experiment, invalid_id, missing_arms, invalid_arm_id,
scoring_failed, manager_unavailable, malformed_entry)
- lets the caller pick the status code: 422 when a non-empty batch
produced zero useful work, 200 for partial or full success
Partial failures stay 200 on purpose. A page rendering three healthy
containers plus one stale one should still get decisions for the
three, not reject the whole batch because one container is wrong
mid-deploy. The `errors` array surfaces the stale one to the client.
rl.js flushes the `errors` array to `console.warn` and forwards to an
optional `Drupal.rl.onErrors` listener so advanced consumers can wire
an alerting path without patching rl/api.
d021a9f to
b5e169e
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
rl.phpnow returns HTTP 422 with the per-itemerrorsarray instead of 200.DrupalPracticeviolation on the@returndocblock (closing brace indentation).Test plan
errors[].errors[].composer lint/ CIdrupal-lintjob passes.