Unleash / unleash-edge

MIT License
48 stars 8 forks source link

chore: add type for incoming/denormalized context #441

Closed thomasheartman closed 6 months ago

thomasheartman commented 6 months ago

This PR adds a new type: IncomingContext. (We can bikeshed the name. Options include: "RawContext", "UnvalidatedContext", "DenormalizedContext", "InputContext", "RawApiInputContext", "UnparsedContext" or whatever else you might have).

It also includes tests that the conversion into the Context type work as expected.

This PR does not update the endpoints with the new type. I started implementation on it -- and it appears to work just as expected -- but due to the number of endpoints and updates we need to make (plus the extra tests), it makes sense to split it into several PRs.

Edge cases

Edge cases we need to cover (this is checked with the Proxy):

Q: What if the same property name is encoded both on the top level and as part of properties? Which one wins?

A: Properties-level remains. Top-level gets removed.

Q: What if you specify a property called properties which has a string value? Does that get put into the properties property (so that we get properties.properties = "some string"?

A: No. The proxy gives you a 400. This will be handled on the API level and not here. Probably works this way already.

Q: Which properties are excluded from being moved to properties?

A: appName, environment, userId, sessionId, remoteAddress, currentTime