Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Allow certain error codes in recordings #878

Open
Gonzalo-Avalos-Ribas opened this issue Apr 18, 2023 · 0 comments
Open

Allow certain error codes in recordings #878

Gonzalo-Avalos-Ribas opened this issue Apr 18, 2023 · 0 comments
Labels
enhancement New feature or request

Comments

@Gonzalo-Avalos-Ribas
Copy link
Contributor

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[];
}
@Gonzalo-Avalos-Ribas Gonzalo-Avalos-Ribas added the enhancement New feature or request label Apr 18, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

1 participant