Skip to content

Allow certain error codes in recordings #878

@Gonzalo-Avalos-Ribas

Description

@Gonzalo-Avalos-Ribas

We already have a flag that allows us to have errors on recordings. Most of the time we enable the flag recordFailedRequests we still write some code to analyze if the recording has an error type we don't expect, e.g:

  return setupRecording({
    mutateEntry: input.options?.recordFailedRequests
      ? (entry) => {
          if (![200, 401].includes(entry.response.status)) {
            throw new Error(
              `${input.name} should only receive 200 and 401 response codes - got ${entry.response.status}`,
            );
          }
          return mutateRecordingEntry(entry);
        }

We have done this across different integrations, so why don't we move it to the sdk? What we propose it to have a new field, that maybe could be used as the array in the code before.

export interface SetupRecordingInput {
    directory: string;
    name: string;
    redactedRequestHeaders?: string[];
    redactedResponseHeaders?: string[];
    mutateEntry?: (entry: any) => void;
    mutateRequest?: (request: any) => void;
    options?: PollyConfig;
+   allowedErrorCodes?: number[];
}

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or request

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions