fix(iflow): handle null data for cookie auth on new accounts#136
Open
MasuRii wants to merge 2 commits intoMirrowel:devfrom
Open
fix(iflow): handle null data for cookie auth on new accounts#136MasuRii wants to merge 2 commits intoMirrowel:devfrom
MasuRii wants to merge 2 commits intoMirrowel:devfrom
Conversation
When a new iFlow account (that hasn't completed OAuth) uses cookie-based authentication, the API returns null data because no API key exists yet. Changes: - Add explicit null data detection in _fetch_api_key_info_with_cookie() - Create IFlowNoAPIKeyError custom exception with actionable guidance - Provide clear instructions: use OAuth (auto-creates API key) or manually create at platform.iflow.cn This fixes authentication failures for new accounts while maintaining backward compatibility for existing accounts with valid API keys.
Contributor
|
Starting my review of the iFlow cookie auth fix for new accounts. This is a focused change - I'll analyze the new exception class and the null data handling logic. |
Contributor
There was a problem hiding this comment.
Overall Assessment
This is a well-crafted, focused PR that addresses a specific edge case with clear user guidance. The implementation is clean and follows existing patterns in the codebase.
Key Changes Reviewed
- New Exception Class:
IFlowNoAPIKeyErroris well-documented with actionable guidance for users - Null Data Detection: Properly handles the case where new iFlow accounts haven't created an API key yet
- Error Messages: Clear instructions provide two resolution paths (OAuth or manual key creation)
Suggestions for Improvement
- Export Consistency: Consider adding
IFlowNoAPIKeyErrorto the public exports incore/__init__.pyandcore/errors.pyto match the pattern used forCredentialNeedsReauthError - Context Enhancement: Passing account identifier information would help users with multiple credentials identify which account needs attention
Testing Considerations
- Verify the error is properly caught and displayed to users
- Ensure existing accounts with valid API keys continue working without any changes
This PR is ready to merge with or without the suggested improvements.
This review was generated by an AI assistant.
Export IFlowNoAPIKeyError through core error re-exports for consistency with other error classes in the module hierarchy. Pass masked BXAuth identifier when raising IFlowNoAPIKeyError to provide multi-account clarity in error messages and logs.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
When a new iFlow account (that hasn't completed OAuth) uses cookie-based authentication, the API returns null data because no API key exists yet. This PR adds explicit null data detection and a custom exception with actionable guidance for users.
Changes
_fetch_api_key_info_with_cookie()before accessing response fieldsIFlowNoAPIKeyErrorcustom exception with clear instructions for resolutionFiles Changed
src/rotator_library/error_handler.pyIFlowNoAPIKeyErrorexception class with actionable messagesrc/rotator_library/providers/iflow_auth_base.pyTesting Instructions
IFlowNoAPIKeyErrorwith instructions instead of an opaque failureImportant
Adds
IFlowNoAPIKeyErrorto handle null data in cookie-based authentication for new iFlow accounts, providing user guidance._fetch_api_key_info_with_cookie()iniflow_auth_base.pyto handle cases where no API key exists.IFlowNoAPIKeyErrorwith guidance for users on how to resolve the issue.IFlowNoAPIKeyErrorinerror_handler.pywith a message guiding users to set up an API key via OAuth or manually.IFlowNoAPIKeyErroriniflow_auth_base.py.This description was created by
for 0c46c05. You can customize this summary. It will automatically update as commits are pushed.