Skip to content

test: dont try refresh token when using vcr only when regenerating#52

Merged
billybonks merged 1 commit into
mainfrom
tests/fix-outh-vcr
May 18, 2026
Merged

test: dont try refresh token when using vcr only when regenerating#52
billybonks merged 1 commit into
mainfrom
tests/fix-outh-vcr

Conversation

@billybonks
Copy link
Copy Markdown
Contributor

No description provided.

@billybonks billybonks merged commit b5b4ec5 into main May 18, 2026
1 check passed
@billybonks billybonks deleted the tests/fix-outh-vcr branch May 18, 2026 12:22
Copy link
Copy Markdown

@managerbot-app managerbot-app Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Reviewed Changes

Managerbot reviewed 1 out of 2 changed files in this pull request and generated 3 comments.

Files not reviewed (1)
  • README.md
Comments suppressed due to low confidence (0)


def vcr_cassette_path(cassette_name)
direct_path = File.join(VCR.configuration.cassette_library_dir, "#{cassette_name}.yml")
return direct_path if File.exist?(direct_path)
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The vcr_cassette_path method returns the direct path regardless of whether it exists or not when the sanitized path check is reached. However, if neither the direct path nor the sanitized path exist, the method still returns the sanitized path — this is intentional for the File.exist? check in replaying_vcr, but the method name vcr_cassette_path implies it always returns a valid path. Consider renaming to possible_vcr_cassette_path or documenting that the returned path may not exist.

def with_vcr_adapter(provider:, model:, redact_request_body: false)
cassette_name = vcr_cassette_name
match_requests_on = redact_request_body ? %i[method uri] : %i[method uri json_body]
replaying_vcr = oauth_provider?(provider) && File.exist?(vcr_cassette_path(cassette_name))
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

replaying_vcr is determined before the VCR.use_cassette block opens. If VCR itself creates or modifies the cassette file during recording, the File.exist? check happens at the right time (before recording starts). However, there's a subtle issue: if the cassette file exists but is empty or corrupt, replaying_vcr will be true and fake credentials will be used, potentially causing confusing test failures. Consider also checking that the file is non-empty or valid.

end

def oauth_provider?(provider)
%w[anthropic_oauth_messages openai_oauth_codex].include?(provider)
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The oauth_provider? method hardcodes provider names as strings. If new OAuth providers are added in the future, developers need to remember to update this list alongside the load_provider case statement. Consider using a shared constant or deriving this list from the case statement logic to keep them in sync.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant