Page MenuHomePhabricator

More strictly validate X-Experiment-Enrollments-Header
Closed, DuplicatePublicBUG REPORT

Description

It was identified that...

...
It seems that experiments.js's getXExperimentEnrollments method may have a logic issue that, while guarding against bad headers, may not have the exact behavior that was intended.

If the X-Experiment-Enrollments header bears the value which doesn't match the regex (e.g., X-Experiment-Enrollments: boo), the regex may have no matches, and I believe thus experiments.js's getEnrolledExperiment may return an empty value, and then a HoistingError will be thrown instead of a MalformedHeaderError.
....

The expected behavior if encountering zero matches in the regex when the X-Experiment-Enrollments header is present shouldn't be to result in a HoistingError error, bur rather to throw a MalformedHeaderError error.

There may be other considerations, and I'll share them here, but I think we should opt for a simple approach here and just throw a MalformedHeaderError for this case and not overthink it. But, in the interest of other considerations for maintainability and defensive coding / smart graceful failures: this could require a little extra thought. On the one hand, we may want to allow through non-A/B test events if they're otherwise well-formed, because that would likely be a case of some misconfiguration independent of anything to do with the event (and that misconfiguration may really not be problematic). On the other hand, if the type of event is an A/B test event, then a malformed header is an error case that is "more" specious. On the other other hand we really don't want to be seeing this header badly behaved under any circumstance (other than us ourselves intentionally inducing it, the purpose of which is to make sure our handling is correct for this very special circumstance).

Event Timeline

Also for consideration: T396359#11047999

the /v1/events API allows for POSTing an array of events, each of which could potentially be a for a different stream or schema.

So, the eventgate API will allow for POSTing batches of events. Some could be ExP events, others could be non ExP events. However, since the header is present via the HTTP request, and will be checked for each of these events, whatever logic is chosen here will impact if this happens.

I don't think any external clients (eventlogging? MP?) submit batches of events as arrays in a single request, but they could!

Groomed today, and we think this one could be handled by ExP. DE can help with review and deployment. TY!

Milimetric moved this task from Incoming to READY TO GROOM on the Test Kitchen board.
Milimetric added a project: Essential-Work.

T409106: X-Experiment-Enrollments EventGate handling reinforcement for MalformedHeaderError cases is more prescriptive about improvement to current state handling and error logging. Now, we may want to think about more advanced handling as in the Description of this task later, too. I'll leave this here task open for consideration of how we may or may not want to allow graceful handling for message processing later on, although T409106 would be the next interim action.

Milimetric subscribed.

DE doesn't plan to work on this, but we'll discuss in our sync-up meeting