frappe / frappe/flow_client

Browser autofills hidden api_key override field on Flow Model, breaking provider authentication

Open
#103 0 comments 0 reactions 0 assignees View on GitHub
Dominant language
Python
Stars
69
Forks
28
PR merge metrics
No merged PRs in 30d

Description

**Title:** Browser autofills hidden `api_key` override field on Flow Model, breaking provider authentication

**Description:**
When a user configures an API key inside a `Flow Provider`, the `api_key` override field in the linked `Flow Model` DocType is typically hidden. However, because the hidden field is still rendered as a password input in the DOM, browser password managers aggressively autofill it with the user's saved Frappe site password (e.g., the `Administrator` login password).

Because Frappe serializes and saves hidden fields, simply clicking "Save" on the `Flow Model` document silently writes the autofilled login password into the database as the model's override key. Since `FlowModel.test_connection` and LiteLLM prioritize the model's override key over the global Provider key, the API call fails with an invalid credential error.

**Steps to Reproduce:**
1. Create a `Flow Provider` and save a valid API key.
2. Ensure your browser (or password manager) has a saved login password for your Frappe instance.
3. Open a `Flow Model` record linked to that Provider. The model's `api_key` field will be hidden.
4. Save the `Flow Model` document.
5. Click **Test Connection**. The request will fail because it is sending the site login password instead of the provider's API key.

**Expected Behavior:**
Hidden password fields should not capture autofilled credentials, preventing the user's login password from accidentally overriding the Provider's configuration.

**Suggested Fixes:**
1. Add `autocomplete="new-password"` to the `api_key` field's HTML attributes to deter aggressive browser autofill.
2. Alternatively, implement a standard Frappe client script (`on_save` hook) in `Flow Model` that explicitly clears the `api_key` field before saving if the field is currently hidden by its `depends_on` condition.

Contributor guide

No contributing guide indexed for this repository

Research direction

Start at the Flow Model DocType's hidden api_key field and its Test Connection flow; reproduce the issue with a saved Frappe password and inspect the field before saving. Done when saving a model does not persist the autofilled login password and Test Connection continues using the linked Provider key.

Written by the indexing model from the issue text.

Assessment

Tech stack
javascript, python
Domain
authentication, security
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Active
Clarity
Mostly clear
Newbie friendliness
72/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.