Skip to content

Fix regexes on Erlang/OTP 28 #889

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
May 21, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 0 additions & 1 deletion lib/sentry/config.ex
Original file line number Diff line number Diff line change
Expand Up @@ -374,7 +374,6 @@ defmodule Sentry.Config do
type:
{:list,
{:custom, __MODULE__, :__validate_struct__, [:source_code_exclude_patterns, Regex]}},
default: [~r"/_build/", ~r"/deps/", ~r"/priv/", ~r"/test/"],
type_doc: "list of `t:Regex.t/0`",
doc: """
A list of regular expressions used to determine which files to
Expand Down
8 changes: 7 additions & 1 deletion lib/sentry/sources.ex
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,13 @@ defmodule Sentry.Sources do
config = Sentry.Config.validate!(config)

path_pattern = Keyword.fetch!(config, :source_code_path_pattern)
exclude_patterns = Keyword.fetch!(config, :source_code_exclude_patterns)

exclude_patterns =
Keyword.get(
config,
:source_code_exclude_patterns,
[~r"/_build/", ~r"/deps/", ~r"/priv/", ~r"/test/"]
)

config
|> Keyword.fetch!(:root_source_code_paths)
Expand Down
14 changes: 5 additions & 9 deletions test/sentry/config_test.exs
Original file line number Diff line number Diff line change
Expand Up @@ -93,15 +93,11 @@ defmodule Sentry.ConfigTest do
end

test ":source_code_exclude_patterns" do
assert Config.validate!(source_code_exclude_patterns: [])[:source_code_exclude_patterns] ==
[]

assert Config.validate!([])[:source_code_exclude_patterns] == [
~r"/_build/",
~r"/deps/",
~r"/priv/",
~r"/test/"
]
assert Config.validate!([])[:source_code_exclude_patterns] == nil

regex = ~r/foo/
config = [source_code_exclude_patterns: [regex]]
assert Config.validate!(config)[:source_code_exclude_patterns] == [regex]

message = ~r/invalid list in :source_code_exclude_patterns option/

Expand Down