bito-code-review[bot] commented on PR #44709:
URL: https://github.com/apache/superset/pull/44709#issuecomment-5846268034
<!-- Bito Reply -->
The flagged issue is correct. When both `username` and `user_token` are
provided, the current implementation overwrites the `adapter_kwargs`
dictionary, which can lead to the loss of other necessary configuration
parameters (like the `subject` or `catalog`) that were previously stored there.
To resolve this, you should use `setdefault` to ensure you are merging the
new `access_token` into the existing `gsheetsapi` configuration rather than
replacing the entire dictionary. The implementation in the provided diff
already correctly uses `setdefault` to avoid this issue:
```python
connect_args = engine_kwargs.setdefault("connect_args", {})
adapter_kwargs = connect_args.setdefault("adapter_kwargs", {})
adapter_kwargs.setdefault("gsheetsapi", {})["access_token"] =
user_token
```
This approach preserves existing keys in `adapter_kwargs` and `gsheetsapi`.
**superset/db_engine_specs/gsheets.py**
```
connect_args = engine_kwargs.setdefault("connect_args", {})
adapter_kwargs = connect_args.setdefault("adapter_kwargs", {})
adapter_kwargs.setdefault("gsheetsapi", {})["access_token"] =
user_token
```
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]