Skip to content

fix(iflow): handle null data for cookie auth on new accounts#136

Open
MasuRii wants to merge 2 commits intoMirrowel:devfrom
MasuRii:fix/iflow-cookie-auth-new-accounts
Open

fix(iflow): handle null data for cookie auth on new accounts#136
MasuRii wants to merge 2 commits intoMirrowel:devfrom
MasuRii:fix/iflow-cookie-auth-new-accounts

Conversation

@MasuRii
Copy link
Contributor

@MasuRii MasuRii commented Feb 17, 2026

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

  • Add explicit null data detection in _fetch_api_key_info_with_cookie() before accessing response fields
  • Create IFlowNoAPIKeyError custom exception with clear instructions for resolution
  • Provide two remediation paths: OAuth authentication (auto-creates API key) or manual creation at platform.iflow.cn

Files Changed

File Type Impact
src/rotator_library/error_handler.py Modified Added IFlowNoAPIKeyError exception class with actionable message
src/rotator_library/providers/iflow_auth_base.py Modified Added null data check and import for new exception

Testing Instructions

  1. Configure a new iFlow account (without an API key) using cookie-based authentication
  2. Attempt to use the proxy - should receive a clear IFlowNoAPIKeyError with instructions instead of an opaque failure
  3. Verify existing accounts with valid API keys continue to work without changes

Important

Adds IFlowNoAPIKeyError to handle null data in cookie-based authentication for new iFlow accounts, providing user guidance.

  • Behavior:
    • Adds null data detection in _fetch_api_key_info_with_cookie() in iflow_auth_base.py to handle cases where no API key exists.
    • Raises IFlowNoAPIKeyError with guidance for users on how to resolve the issue.
  • Exceptions:
    • Introduces IFlowNoAPIKeyError in error_handler.py with a message guiding users to set up an API key via OAuth or manually.
  • Imports:
    • Adds import for IFlowNoAPIKeyError in iflow_auth_base.py.

This description was created by Ellipsis for 0c46c05. You can customize this summary. It will automatically update as commits are pushed.

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.
@MasuRii MasuRii requested a review from Mirrowel as a code owner February 17, 2026 08:26
@mirrobot-agent
Copy link
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.

Copy link
Contributor

@mirrobot-agent mirrobot-agent bot left a comment

Choose a reason for hiding this comment

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

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: IFlowNoAPIKeyError is 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

  1. Export Consistency: Consider adding IFlowNoAPIKeyError to the public exports in core/__init__.py and core/errors.py to match the pattern used for CredentialNeedsReauthError
  2. 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.
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

Comments