kaxil commented on code in PR #76710:
URL: https://github.com/apache/airflow/pull/76710#discussion_r4518307298


##########
providers/sqlite/src/airflow/providers/sqlite/hooks/sqlite.py:
##########
@@ -31,6 +32,20 @@ class SqliteHook(DbApiHook):
     conn_type = "sqlite"
     hook_name = "Sqlite"
 
+    @classmethod
+    def get_ui_field_behaviour(cls) -> dict[str, Any]:
+        """Return custom UI field behaviour for SQLite connection."""
+        return {
+            "hidden_fields": ["port", "schema", "login", "password"],

Review Comment:
   Hiding `login` and `password` also removes the way to repair a connection 
that already has them set: the edit form only sends changed fields in 
`update_mask`, so the stored values stay and `get_uri()` keeps building 
`file:user:pass@...`. Connections from env vars, secrets backends and the CLI 
aren't covered by a UI change either. Would it be better to have `get_uri()` 
ignore (or raise on) `login`/`password`/`port`, so the fix applies to every 
path and not only the form?



##########
providers/sqlite/provider.yaml:
##########
@@ -90,3 +90,14 @@ connection-types:
   - hook-class-name: airflow.providers.sqlite.hooks.sqlite.SqliteHook
     hook-name: "Sqlite"
     connection-type: sqlite
+    ui-field-behaviour:
+      hidden-fields:
+        - port
+        - schema

Review Comment:
   `schema` isn't unused for SQLite. A connection defined by URI keeps its path 
there: `sqlite:///absolute/path/to/db` (the form `docs/connections/sqlite.rst` 
documents) parses to `host=''` and `schema='absolute/path/to/db'`, and 
`sqlite://relative/path/to/db` to `host='relative'`, `schema='path/to/db'`. 
`get_uri()` rebuilds the file path from both. With `schema` hidden, editing one 
of these shows an empty "File path" under the in-memory placeholder, and typing 
the path there appends the hidden `schema` to it, so a connection that worked 
stops opening. Can `schema` stay visible here, in the hook and in the test?



##########
providers/sqlite/tests/unit/sqlite/hooks/test_sqlite.py:
##########
@@ -235,3 +235,15 @@ def test_sqlalchemy_engine(self):
         assert engine.name == "sqlite"
         # Assert filepath of the sqliate DB is correct
         assert engine.url.database == hook.get_connection(conn_id).host
+
+    def test_get_ui_field_behaviour(self):

Review Comment:
   This repeats the hook's dict, so it only fails when one copy is edited and 
not the other. `check_ui_field_behaviour_matches_hook` already keeps the hook 
and `provider.yaml` in sync. Asserting what the change is about (e.g. `login` 
and `password` are in `hidden_fields`) would be enough.



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

Reply via email to