Skip to content

Conversation

@solnic
Copy link
Collaborator

@solnic solnic commented Dec 1, 2025

#skip-changelog

Before

± mix test
warning: setting :preferred_cli_env in your mix.exs "def project" is deprecated, set it inside "def cli" instead:

    def cli do
      [preferred_envs: ["coveralls.html": :test, "test.integrations": :test]]
    end

  (mix 1.19.3) lib/mix/cli.ex:187: Mix.CLI.preferred_cli_env/3
  (mix 1.19.3) lib/mix/cli.ex:170: Mix.CLI.maybe_change_env_and_target/2
  (mix 1.19.3) lib/mix/cli.ex:59: Mix.CLI.proceed/2
  /usr/local/bin/mix:7: (file)
  (elixir 1.19.3) src/elixir_compiler.erl:81: :elixir_compiler.dispatch/4
  (elixir 1.19.3) src/elixir_compiler.erl:56: :elixir_compiler.compile/4

Compiling 54 files (.ex)
Generated sentry app
Wrote 145 files in 675.99 kb to: _build/test/lib/sentry/priv/sentry.map
warning: the :backends key for the :logger application is deprecated.
Here is how to proceed:

1. If you want to set it to [:console], simply remove the option.

2. If you want to disable logging, remove :backends and instead set:

    config :logger, :default_handler, false

3. If you want to configure any other backend, then it is recommended
   to add `{:logger_backends, "~> 1.0"}` as a dependency and call
   `LoggerBackends.add(CustomBackend)` in your application start callback

  (logger 1.19.3) lib/logger/app.ex:20: Logger.App.start/2
  (kernel 10.4) application_master.erl:299: :application_master.start_it_old/4

warning: the following files do not match any of the configured `:test_load_filters` / `:test_ignore_filters`:

test/fixtures/example-umbrella-app-with-conflict/apps/app_a/lib/module_a.ex
test/fixtures/example-umbrella-app-with-conflict/apps/app_b/lib/module_a.ex
test/fixtures/example-umbrella-app/apps/app_a/lib/module_a.ex
test/fixtures/example-umbrella-app/apps/app_b/lib/module_b.ex

This might indicate a typo in a test file name (for example, using "foo_tests.exs" instead of "foo_test.exs").

See the configuration for `:test_pattern` under `mix help test` for more information.

Running ExUnit with seed: 631241, max_cases: 32

.........................................     warning: a struct for Sentry.Event is expected on struct update:

         %Sentry.Event{
           event
           | extra: Map.merge(event.extra, rest_metadata),
             user: Map.put(event.user, :id, user_id)
         }

     but got type:

         dynamic()

     where "event" was given the type:

         # type: dynamic()
         # from: test/sentry/client_test.exs:231:25
         event

     when defining the variable "event", you must also pattern match on "%Sentry.Event{}".

     hint: given pattern matching is enough to catch typing errors, you may optionally convert the struct update into a map update. For example, instead of:

         user = some_function()
         %User{user | name: "John Doe"}

     it is enough to write:

         %User{} = user = some_function()
         %{user | name: "John Doe"}

     typing violation found at:
     │
 235 │           %Event{
     │           ~
     │
     └─ test/sentry/client_test.exs:235:11: Sentry.ClientTest."test send_event/2 calls anonymous :before_send callback"/1

.............................................................................................................................................................................................................................................................................................................................................................................warning: the :backends key for the :logger application is deprecated.
Here is how to proceed:

1. If you want to set it to [:console], simply remove the option.

2. If you want to disable logging, remove :backends and instead set:

    config :logger, :default_handler, false

3. If you want to configure any other backend, then it is recommended
   to add `{:logger_backends, "~> 1.0"}` as a dependency and call
   `LoggerBackends.add(CustomBackend)` in your application start callback

  (logger 1.19.3) lib/logger/app.ex:20: Logger.App.start/2
  (kernel 10.4) application_master.erl:299: :application_master.start_it_old/4

warning: the :backends key for the :logger application is deprecated.
Here is how to proceed:

1. If you want to set it to [:console], simply remove the option.

2. If you want to disable logging, remove :backends and instead set:

    config :logger, :default_handler, false

3. If you want to configure any other backend, then it is recommended
   to add `{:logger_backends, "~> 1.0"}` as a dependency and call
   `LoggerBackends.add(CustomBackend)` in your application start callback

  (logger 1.19.3) lib/logger/app.ex:20: Logger.App.start/2
  (kernel 10.4) application_master.erl:299: :application_master.start_it_old/4

......warning: the :backends key for the :logger application is deprecated.
Here is how to proceed:

1. If you want to set it to [:console], simply remove the option.

2. If you want to disable logging, remove :backends and instead set:

    config :logger, :default_handler, false

3. If you want to configure any other backend, then it is recommended
   to add `{:logger_backends, "~> 1.0"}` as a dependency and call
   `LoggerBackends.add(CustomBackend)` in your application start callback

  (logger 1.19.3) lib/logger/app.ex:20: Logger.App.start/2
  (kernel 10.4) application_master.erl:299: :application_master.start_it_old/4

warning: the :backends key for the :logger application is deprecated.
Here is how to proceed:

1. If you want to set it to [:console], simply remove the option.

2. If you want to disable logging, remove :backends and instead set:

    config :logger, :default_handler, false

3. If you want to configure any other backend, then it is recommended
   to add `{:logger_backends, "~> 1.0"}` as a dependency and call
   `LoggerBackends.add(CustomBackend)` in your application start callback

  (logger 1.19.3) lib/logger/app.ex:20: Logger.App.start/2
  (kernel 10.4) application_master.erl:299: :application_master.start_it_old/4

...............
Finished in 12.0 seconds (1.6s async, 10.3s sync)
14 doctests, 413 tests, 0 failures

After

± mix test
Compiling 54 files (.ex)
Generated sentry app
Wrote 145 files in 675.99 kb to: _build/test/lib/sentry/priv/sentry.map
Running ExUnit with seed: 861624, max_cases: 32

...........................................................................................................................................................................................................................................................................................................................................................................................................................................
Finished in 12.1 seconds (1.9s async, 10.2s sync)
14 doctests, 413 tests, 0 failures

warning: the following files do not match any of the configured `:test_load_filters` / `:test_ignore_filters`:

test/fixtures/example-umbrella-app-with-conflict/apps/app_a/lib/module_a.ex
test/fixtures/example-umbrella-app-with-conflict/apps/app_b/lib/module_a.ex
test/fixtures/example-umbrella-app/apps/app_a/lib/module_a.ex
test/fixtures/example-umbrella-app/apps/app_b/lib/module_b.ex

This might indicate a typo in a test file name (for example, using "foo_tests.exs" instead of "foo_test.exs").

See the configuration for `:test_pattern` under `mix help test` for more information.
@solnic solnic force-pushed the solnic/fix-warnings branch from 960bd05 to ea3a7e3 Compare December 1, 2025 15:35
@solnic solnic merged commit ffc7b51 into master Dec 1, 2025
10 checks passed
@solnic solnic deleted the solnic/fix-warnings branch December 1, 2025 15:38
Comment on lines +235 to 238
%{
event
| extra: Map.merge(event.extra, rest_metadata),
user: Map.put(event.user, :id, user_id)
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Bug: The before_send callback returns a plain map instead of an Event struct, preventing Sentry events from being sent.
Severity: CRITICAL | Confidence: High

🔍 Detailed Analysis

The before_send callback in test/sentry/client_test.exs (lines 235-238) returns a plain map %{...} instead of an %Event{} struct. This causes the with block in Client.send_event/2 to fail its pattern match {:ok, %Event{} = event}, preventing the event from being sent to the Sentry server. Consequently, the Bypass.expect in the test fails due to no HTTP request being made.

💡 Suggested Fix

Modify the before_send callback to ensure it returns an %Event{} struct, not a plain map. Update the existing event struct and return it directly.

🤖 Prompt for AI Agent
Review the code at the location below. A potential bug has been identified by an AI
agent.
Verify if this is a real issue. If it is, propose a fix; if not, explain why it's not
valid.

Location: test/sentry/client_test.exs#L235-L238

Potential issue: The `before_send` callback in `test/sentry/client_test.exs` (lines
235-238) returns a plain map `%{...}` instead of an `%Event{}` struct. This causes the
`with` block in `Client.send_event/2` to fail its pattern match `{:ok, %Event{} =
event}`, preventing the event from being sent to the Sentry server. Consequently, the
`Bypass.expect` in the test fails due to no HTTP request being made.

Did we get this right? 👍 / 👎 to inform future reviews.
Reference ID: 4581160

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants