Git Product home page Git Product logo

Comments (12)

whatyouhide avatar whatyouhide commented on June 10, 2024

Hi @anthonator, thanks for the report. I'd need a bit more info in order to debug this.

  1. What's the error that you're seeing in the logs, that gets reported as the screenshot above?
  2. Is your Sentry project configured as an Elixir project (on Sentry)?
  3. Do you have a way to reproduce this with a minimal Elixir app?

from sentry-elixir.

anthonator avatar anthonator commented on June 10, 2024

Thanks for getting back to me!

What's the error that you're seeing in the logs, that gets reported as the screenshot above?

2024-02-06 11:32:19.831** (exit) an exception was raised: | 2024-02-06 11:32:19.831 | ** (exit) an exception was raised: |  
-- | -- | -- | --
2024-02-06 11:32:19.831 | ** (exit) an exception was raised: |  

2024-02-06 11:32:19.831    ** (Ecto.ConstraintError) constraint error when attempting to insert struct: |   |   | 2024-02-06 11:32:19.831 | ** (Ecto.ConstraintError) constraint error when attempting to insert struct: |  
  |   | 2024-02-06 11:32:19.831 | ** (Ecto.ConstraintError) constraint error when attempting to insert struct: |  
2024-02-06 11:32:19.8312024-02-06 11:32:19.831    * "***_index" (unique_constraint)2024-02-06 11:32:19.8312024-02-06 11:32:19.831If you would like to stop this constraint violation from raising an2024-02-06 11:32:19.831exception and instead add it as an error to your changeset, please2024-02-06 11:32:19.831call `unique_constraint/3` on your changeset with the constraint2024-02-06 11:32:19.831`:name` as an option.2024-02-06 11:32:19.8312024-02-06 11:32:19.831The changeset defined the following constraints:2024-02-06 11:32:19.8312024-02-06 11:32:19.831    * "***_index" (unique_constraint)2024-02-06 11:32:19.8312024-02-06 11:32:19.831        (ecto 3.10.3) lib/ecto/repo/schema.ex:804: anonymous fn/4 in Ecto.Repo.Schema.constraints_to_errors/32024-02-06 11:32:19.831        (elixir 1.14.5) lib/enum.ex:1658: Enum."-map/2-lists^map/1-0-"/22024-02-06 11:32:19.831        (ecto 3.10.3) lib/ecto/repo/schema.ex:788: Ecto.Repo.Schema.constraints_to_errors/32024-02-06 11:32:19.831        (ecto 3.10.3) lib/ecto/repo/schema.ex:769: Ecto.Repo.Schema.apply/42024-02-06 11:32:19.831        (ecto 3.10.3) lib/ecto/repo/schema.ex:377: anonymous fn/15 in Ecto.Repo.Schema.do_insert/42024-02-06 11:32:19.831        (ecto 3.10.3) lib/ecto/multi.ex:844: Ecto.Multi.apply_operation/52024-02-06 11:32:19.831        (elixir 1.14.5) lib/enum.ex:2468: Enum."-reduce/3-lists^foldl/2-0-"/32024-02-06 11:32:19.831        (ecto 3.10.3) lib/ecto/multi.ex:818: anonymous fn/5 in Ecto.Multi.apply_operations/5 |   |   | 2024-02-06 11:32:19.831 |   |   |   |   | 2024-02-06 11:32:19.831 | * "***_index" (unique_constraint) |   |   |   | 2024-02-06 11:32:19.831 |   |   |   |   | 2024-02-06 11:32:19.831 | If you would like to stop this constraint violation from raising an |   |   |   | 2024-02-06 11:32:19.831 | exception and instead add it as an error to your changeset, please |   |   |   | 2024-02-06 11:32:19.831 | call `unique_constraint/3` on your changeset with the constraint |   |   |   | 2024-02-06 11:32:19.831 | `:name` as an option. |   |   |   | 2024-02-06 11:32:19.831 |   |   |   |   | 2024-02-06 11:32:19.831 | The changeset defined the following constraints: |   |   |   | 2024-02-06 11:32:19.831 |   |   |   |   | 2024-02-06 11:32:19.831 | * "***_index" (unique_constraint) |   |   |   | 2024-02-06 11:32:19.831 |   |   |   |   | 2024-02-06 11:32:19.831 | (ecto 3.10.3) lib/ecto/repo/schema.ex:804: anonymous fn/4 in Ecto.Repo.Schema.constraints_to_errors/3 |   |   |   | 2024-02-06 11:32:19.831 | (elixir 1.14.5) lib/enum.ex:1658: Enum."-map/2-lists^map/1-0-"/2 |   |   |   | 2024-02-06 11:32:19.831 | (ecto 3.10.3) lib/ecto/repo/schema.ex:788: Ecto.Repo.Schema.constraints_to_errors/3 |   |   |   | 2024-02-06 11:32:19.831 | (ecto 3.10.3) lib/ecto/repo/schema.ex:769: Ecto.Repo.Schema.apply/4 |   |   |   | 2024-02-06 11:32:19.831 | (ecto 3.10.3) lib/ecto/repo/schema.ex:377: anonymous fn/15 in Ecto.Repo.Schema.do_insert/4 |   |   |   | 2024-02-06 11:32:19.831 | (ecto 3.10.3) lib/ecto/multi.ex:844: Ecto.Multi.apply_operation/5 |   |   |   | 2024-02-06 11:32:19.831 | (elixir 1.14.5) lib/enum.ex:2468: Enum."-reduce/3-lists^foldl/2-0-"/3 |   |   |   | 2024-02-06 11:32:19.831 | (ecto 3.10.3) lib/ecto/multi.ex:818: anonymous fn/5 in Ecto.Multi.apply_operations/5
  |   | 2024-02-06 11:32:19.831 |   |  
  |   | 2024-02-06 11:32:19.831 | * "***_index" (unique_constraint) |  
  |   | 2024-02-06 11:32:19.831 |   |  
  |   | 2024-02-06 11:32:19.831 | If you would like to stop this constraint violation from raising an |  
  |   | 2024-02-06 11:32:19.831 | exception and instead add it as an error to your changeset, please |  
  |   | 2024-02-06 11:32:19.831 | call `unique_constraint/3` on your changeset with the constraint |  
  |   | 2024-02-06 11:32:19.831 | `:name` as an option. |  
  |   | 2024-02-06 11:32:19.831 |   |  
  |   | 2024-02-06 11:32:19.831 | The changeset defined the following constraints: |  
  |   | 2024-02-06 11:32:19.831 |   |  
  |   | 2024-02-06 11:32:19.831 | * "***_index" (unique_constraint) |  
  |   | 2024-02-06 11:32:19.831 |   |  
  |   | 2024-02-06 11:32:19.831 | (ecto 3.10.3) lib/ecto/repo/schema.ex:804: anonymous fn/4 in Ecto.Repo.Schema.constraints_to_errors/3 |  
  |   | 2024-02-06 11:32:19.831 | (elixir 1.14.5) lib/enum.ex:1658: Enum."-map/2-lists^map/1-0-"/2 |  
  |   | 2024-02-06 11:32:19.831 | (ecto 3.10.3) lib/ecto/repo/schema.ex:788: Ecto.Repo.Schema.constraints_to_errors/3 |  
  |   | 2024-02-06 11:32:19.831 | (ecto 3.10.3) lib/ecto/repo/schema.ex:769: Ecto.Repo.Schema.apply/4 |  
  |   | 2024-02-06 11:32:19.831 | (ecto 3.10.3) lib/ecto/repo/schema.ex:377: anonymous fn/15 in Ecto.Repo.Schema.do_insert/4 |  
  |   | 2024-02-06 11:32:19.831 | (ecto 3.10.3) lib/ecto/multi.ex:844: Ecto.Multi.apply_operation/5 |  
  |   | 2024-02-06 11:32:19.831 | (elixir 1.14.5) lib/enum.ex:2468: Enum."-reduce/3-lists^foldl/2-0-"/3 |  
  |   | 2024-02-06 11:32:19.831 | (ecto 3.10.3) lib/ecto/multi.ex:818: anonymous fn/5 in Ecto.Multi.apply_operations/5

Is your Sentry project configured as an Elixir project (on Sentry)?

No, it is not. Although this hasn't been an issue for projects using v8.

Do you have a way to reproduce this with a minimal Elixir app?

No, not currently

from sentry-elixir.

whatyouhide avatar whatyouhide commented on June 10, 2024

No, it is not. Although this hasn't been an issue for projects using v8.

If you change the project type to Elixir, does that change anything?

No, not currently

It's really hard for me to help debug this without any way to reproduce it 😢. All my tests point to errors showing up correctly, and we're on 10.1.0 at work and errors also show up correctly (also with Cowboy + Phoenix).

from sentry-elixir.

anthonator avatar anthonator commented on June 10, 2024

I recently upgraded another project to v10.1.0 and we're seeing the same issue. The Sentry project for this application is set as Elixir. Everything worked perfectly using v8.x.

If I have time I'll try to put together a minimal reproduction app.

Here are some additional details.

This is the first line of start/2 in our Application module:

:logger.add_handler(:sentry_handler, Sentry.LoggerHandler, %{})

We also removed all use of Sentry.LoggerBackend.

This is the first line of our endpont:

use Sentry.PlugCapture

The runtime.exs looks like this.

if config_env() == :prod do
  config :sentry,
    dsn: System.get_env("SENTRY_DSN"),
    enable_source_code_context: true,
    environment_name: System.get_env("SENTRY_ENV"),
    hackney_opts: [
      ssl_options: [
        cacertfile: :certifi.cacertfile(),
        customize_hostname_check: [match_fun: :public_key.pkix_verify_hostname_match_fun(:https)],
        verify: :verify_peer,
        verify_fun: &:ssl_verify_hostname.verify_fun/3,
        versions: [:"tlsv1.2", :"tlsv1.3"]
      ]
    ],
    root_source_code_paths: [File.cwd!()]
end

This is how we create the release in our Dockerfile:

RUN apk upgrade --no-cache \
    && mix deps.get \
    && mix compile \
    && mix app.config \
    && mix sentry.package_source_code \
    && mix release

Here's another example of what we're seeing in Sentry.

Screenshot 2024-02-08 at 11 23 41 AM

from sentry-elixir.

anthonator avatar anthonator commented on June 10, 2024

Just tried moving some Sentry config to config.exs to see if there's a problem with the source mapping. Still seeing the same issue.

config.exs

config :sentry,
  enable_source_code_context: true,
  root_source_code_paths: [File.cwd!()]

runtime.exs

if config_env() == :prod do
  config :sentry,
    dsn: System.get_env("SENTRY_DSN"),
    environment_name: System.get_env("SENTRY_ENV"),
    hackney_opts: [
      ssl_options: [
        cacertfile: :certifi.cacertfile(),
        customize_hostname_check: [match_fun: :public_key.pkix_verify_hostname_match_fun(:https)],
        verify: :verify_peer,
        verify_fun: &:ssl_verify_hostname.verify_fun/3,
        versions: [:"tlsv1.2", :"tlsv1.3"]
      ]
    ]
end

When I run MIX_ENV=prod mix sentry.package_source_code, I see:

Wrote 207 files in 139.6 kb to: _build/prod/lib/sentry/priv/sentry.map

When I make a release I can see sentry.map in _build/prod/rel/myapp/lib/sentry-10.1.0/priv.

from sentry-elixir.

anthonator avatar anthonator commented on June 10, 2024

When I call Sentry.Sources.get_source_code_map_from_persistent_term() I don't see any maps for anything outside of my projects lib/ directory. So no dependencies. The errors I'm seeing that have this issue seem to be coming from dependencies.

Not sure if this is relevant but thought I'd share.

from sentry-elixir.

anthonator avatar anthonator commented on June 10, 2024

Tried removing deps/ from the exclude list with source_code_exclude_patterns: [~r/\/_build\//, ~r/\/priv\//, ~r/\/test\//].

I could see that more files were being added to the source map but still the same result.

from sentry-elixir.

whatyouhide avatar whatyouhide commented on June 10, 2024

This has nothing to do with whether dependencies are in the source map, no. What did that same error look like before the upgrade, do you have any examples?

from sentry-elixir.

anthonator avatar anthonator commented on June 10, 2024

I don't have a good 1-to-1 but here is another error that we see the issue with in 10.1.0. After downgrading to 8.1.0 this is what we see.

Screenshot 2024-02-08 at 4 19 51 PM

from sentry-elixir.

whatyouhide avatar whatyouhide commented on June 10, 2024

@anthonator did you have a chance to get a reproduceable example? Also, we did some changes in the :logger handler, so might be worth trying out 10.4.0.

For now, I will close this as I have no way to reproduce this, but we can reopen if anything pops up.

from sentry-elixir.

anthonator avatar anthonator commented on June 10, 2024

I have not been able to get a reproducible example together, unfortunately. However, this is still an issue for us. Only thing we’ve been able to do is downgrade to 8.x. All versions 9+ have exhibited this behavior.

Thanks for helping where you could on this.

from sentry-elixir.

whatyouhide avatar whatyouhide commented on June 10, 2024

If you shared how the whole error looks like on Sentry I might be able to help. Feel free to reach out at [email protected] if that contains private data, but with the current information I cannot reproduce this sadly.

from sentry-elixir.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.