Skip to content

Commit

Permalink
feat: Support for SPS-Execution-Context Custom Header (#39)
Browse files Browse the repository at this point in the history
SPS Commerce will need to support a non-invasive method of applying customer/dataflow context to services. This is used internally by support to interact with services during custom configuration modifications, and eventually useable by external customers to test their own variations in non-production data contexts at times. This introduces the SPS-Execution-Context Request/Response Custom Header.
  • Loading branch information
travisgosselin authored Aug 31, 2023
1 parent cc71f4c commit 0bae3fa
Showing 1 changed file with 33 additions and 0 deletions.
33 changes: 33 additions & 0 deletions standards/request-response.md
Original file line number Diff line number Diff line change
Expand Up @@ -493,6 +493,39 @@ The usage of non-standard headers is not considered custom headers. For example,
SPS-CORS-Error: bad origin
```

#### SPS-Execution-Context

**Type**: Both

**Support**: OPTIONAL

**Description**: The Execution Context header provides a standard method of indicating the dataflow context that a request should be processed with. This is used to differentiate or test changes in customer configuration of non-production data. This isolates the version of the configuration state used in a request and allows identifying transactions that should leverage a specific tagged or aliased configuration set.

- A request without the presence of this header **MUST** indicate that the execution context is under the `production` dataflow and customer configuration, if applicable to this API.
- The header value contains any dynamic __string__ value representing a named configuration or tagged dataflow preset.
- __preprod__ - Well-known value used to represent non-production customer configuration and can be supported as a static mode in some legacy services without full dynamic support. Usage of dynamically named configuration sets is preferred.
-__prod__ - Well-known value used to represent production customer configuration and can be supported as a static mode in some legacy services without full dynamic support. Usage of dynamically named configuration sets is preferred. When no request or response header is provided for `SPS-Execution-Context` this is interpreted as the default value.
- An invalid or unsupported header value provided **MUST** result in a `400 - Bad Request` following standard [error format](errors.md#400-bad-request).
- The header value **MUST** be at minimum 1 character in length and **MUST NOT** exceed a maximum length of 100 characters.
- The header value **SHOULD** contain human-readable tag for the context.
- The header **SHOULD** be propagated to any outgoing requests to retain the context for downstream usage.
- The header **MUST** be supplied in the response for every request containing the header, and match the original requested value.
- The header **SHOULD** be supplied in the response for every request in general, if applicable to the API, even if just defaulting to __prod__.

**Example(s)**:

```
// CORRECT
SPS-Execution-Context: prod
SPS-Execution-Context: preprod
SPS-Execution-Context: customer-testing
SPS-Execution-Context: example-customer-configuration
// INCORRECT
SPS-Execution-Context: // values must be at least a character long.
SPS-Execution-Context: 1 // valid, but SHOULD be human-readable.
```

## MIME Types

### Standard MIME Types
Expand Down

0 comments on commit 0bae3fa

Please sign in to comment.