Adityakk9031 commented on code in PR #69504:
URL: https://github.com/apache/airflow/pull/69504#discussion_r4282789721


##########
task-sdk/src/airflow/sdk/execution_time/sentry/configured.py:
##########
@@ -80,24 +80,28 @@ def prepare_to_enrich_errors(self, executor_integration: 
str) -> None:
                 log.exception("Invalid executor Sentry integration", 
import_path=executor_integration)
 
         sentry_config_opts: dict[str, Any] = conf.getsection("sentry") or {}
-        if sentry_config_opts:
-            sentry_config_opts.pop("sentry_on")
-            old_way_dsn = sentry_config_opts.pop("sentry_dsn", None)
-            new_way_dsn = sentry_config_opts.pop("dsn", None)
-            # supported backward compatibility with old way dsn option
-            dsn = old_way_dsn or new_way_dsn
-
-            if unsupported_options := 
self.UNSUPPORTED_SENTRY_OPTIONS.intersection(sentry_config_opts):
-                log.warning(
-                    "There are unsupported options in [sentry] section",
-                    options=unsupported_options,
-                )
+        sentry_config_opts.pop("sentry_on", None)
+        old_way_dsn = sentry_config_opts.pop("sentry_dsn", None)
+        new_way_dsn = sentry_config_opts.pop("dsn", None)
+        # supported backward compatibility with old way dsn option
+        dsn = old_way_dsn or new_way_dsn
+
+        # Resolve before_send and transport to callables if configured
+        if before_send := conf.getimport("sentry", "before_send", 
fallback=None):
+            sentry_config_opts["before_send"] = before_send
         else:
-            dsn = None
-            if before_send := conf.getimport("sentry", "before_send", 
fallback=None):
-                sentry_config_opts["before_send"] = before_send
-            if transport := conf.getimport("sentry", "transport", 
fallback=None):
-                sentry_config_opts["transport"] = transport
+            sentry_config_opts.pop("before_send", None)
+
+        if transport := conf.getimport("sentry", "transport", fallback=None):
+            sentry_config_opts["transport"] = transport
+        else:
+            sentry_config_opts.pop("transport", None)

Review Comment:
   Done, switched to `import_string` on the popped values (pushed). I could not 
run the Sentry tests locally on Windows because the `_shared` symlinks do not 
resolve, so I am relying on CI.



##########
task-sdk/src/airflow/sdk/execution_time/sentry/configured.py:
##########
@@ -80,24 +80,28 @@ def prepare_to_enrich_errors(self, executor_integration: 
str) -> None:
                 log.exception("Invalid executor Sentry integration", 
import_path=executor_integration)
 
         sentry_config_opts: dict[str, Any] = conf.getsection("sentry") or {}
-        if sentry_config_opts:
-            sentry_config_opts.pop("sentry_on")
-            old_way_dsn = sentry_config_opts.pop("sentry_dsn", None)
-            new_way_dsn = sentry_config_opts.pop("dsn", None)
-            # supported backward compatibility with old way dsn option
-            dsn = old_way_dsn or new_way_dsn
-
-            if unsupported_options := 
self.UNSUPPORTED_SENTRY_OPTIONS.intersection(sentry_config_opts):
-                log.warning(
-                    "There are unsupported options in [sentry] section",
-                    options=unsupported_options,
-                )
+        sentry_config_opts.pop("sentry_on", None)
+        old_way_dsn = sentry_config_opts.pop("sentry_dsn", None)
+        new_way_dsn = sentry_config_opts.pop("dsn", None)
+        # supported backward compatibility with old way dsn option
+        dsn = old_way_dsn or new_way_dsn
+
+        # Resolve before_send and transport to callables if configured
+        if before_send := conf.getimport("sentry", "before_send", 
fallback=None):
+            sentry_config_opts["before_send"] = before_send
         else:
-            dsn = None

Review Comment:
   `dsn` is popped because `sentry_sdk.init(dsn=dsn, integrations=integrations, 
**sentry_config_opts)` would otherwise raise `TypeError: got multiple values 
for keyword argument 'dsn'`. It also lets the deprecated `sentry_dsn` fall back 
to `dsn`. That behaviour is unchanged here, and it should still be popped, so 
that the explicit `dsn=` argument is the only source.



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