dosubot[bot] commented on issue #32862:
URL: https://github.com/apache/superset/issues/32862#issuecomment-2754834311

   <!-- Greeting -->
   Hey @danlewis85! I'm here to assist you with any bugs, questions, or 
contributions while you wait for a human maintainer. Let me know how I can 
help! [Dosu](https://dosu.dev)
   
   <!-- Answer -->
   To address the issue of malformed JSON/dictionary in the 
`get_extra_params()` method affecting the DuckDB connection, you should ensure 
that the `extra` field of the `database` object is correctly parsed as a JSON 
object before accessing it. The test case for the `DuckDBEngineSpec` class 
demonstrates how the `get_extra_params` method should handle the `extra` field:
   
   ```python
   from superset.db_engine_specs.duckdb import DuckDBEngineSpec
   
   database = mocker.MagicMock()
   
   # Case when extra is an empty dictionary
   database.extra = {}
   assert DuckDBEngineSpec.get_extra_params(database) == {
       "engine_params": {
           "connect_args": {
               "config": {"custom_user_agent": 
f"apache-superset/{VERSION_STRING}"}
           }
       }
   }
   
   # Case when extra is a JSON string
   database.extra = json.dumps(
       {"engine_params": {"connect_args": {"config": {"custom_user_agent": 
"my-app"}}}}
   )
   assert DuckDBEngineSpec.get_extra_params(database) == {
       "engine_params": {
           "connect_args": {
               "config": {
                   "custom_user_agent": f"apache-superset/{VERSION_STRING} 
my-app"
               }
           }
       }
   }
   ```
   
   Ensure that the `extra` field is correctly parsed using `json.loads()` if it 
is a JSON string. This will prevent issues with malformed JSON/dictionary 
structures 
<sup>[[1]](https://github.com/apache/superset/blob/master/tests/unit_tests/db_engine_specs/test_duckdb.py)</sup>.
 
   
   Unfortunately, I didn't find any similar threads that might provide 
additional context or solutions.
   
   
   <!-- Dosu Comment Footer -->
   *To continue talking to [Dosu](https://dosu.dev), mention @dosu.*
   
   ---
   <sup>Help Dosu learn! Give it feedback: [Great 
Response](https://app.dosu.dev/response-feedback/c34a8949-73ca-4387-9bd4-f08f5d5e2357?feedback_type=great_response)
 | [Irrelevant 
Answer](https://app.dosu.dev/response-feedback/c34a8949-73ca-4387-9bd4-f08f5d5e2357?feedback_type=irrelevant_answer)
 | [Incorrect 
Sources](https://app.dosu.dev/response-feedback/c34a8949-73ca-4387-9bd4-f08f5d5e2357?feedback_type=incorrect_sources)
 | [Too 
Verbose](https://app.dosu.dev/response-feedback/c34a8949-73ca-4387-9bd4-f08f5d5e2357?feedback_type=too_verbose)
 | 
[Hallucination](https://app.dosu.dev/response-feedback/c34a8949-73ca-4387-9bd4-f08f5d5e2357?feedback_type=hallucination)
 | [Bug 
Report](https://app.dosu.dev/response-feedback/c34a8949-73ca-4387-9bd4-f08f5d5e2357?feedback_type=bug_report)
 | 
[Other](https://app.dosu.dev/response-feedback/c34a8949-73ca-4387-9bd4-f08f5d5e2357?feedback_type=other)</sup>
   


-- 
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]

Reply via email to