Skip to content

fix: resolve Elixir 1.18 #Reference escaping compilation crash - #220

Merged
dustinbyrne merged 2 commits into
PostHog:mainfrom
boxxxie:fix/elixir-1.18-reference-bug
Oct 6, 2026
Merged

dustinbyrne merged 2 commits into
PostHog:mainfrom
boxxxie:fix/elixir-1.18-reference-bug

Conversation

@boxxxie

@boxxxie boxxxie commented Oct 5, 2026

Copy link
Copy Markdown
Contributor

Elixir 1.18.3 and 1.18.4 introduced strict compiler validations that ban #Reference structs (which Regex.compile! and ~r// compile down into internally) from being embedded in module attributes and expanded inside function/macro ASTs.

Because @configuration_schema contained regex defaults for sanitize_uris, attempting to reference it inside read!() caused a fatal crash on Elixir 1.18.4.

This PR refactors the schemas to live inside a separate PostHog.Config.Schema module and references them as standard functions at runtime to cleanly satisfy Elixir 1.18's AST boundaries without breaking functionality.

@boxxxie
boxxxie requested a review from a team as a code owner October 5, 2026 08:21

@marandaneto marandaneto left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

suggestion: Add a patch changeset for this customer-facing compilation fix using sampo add, as described in RELEASING.md. This PR currently contains no changeset, so the fix is missing the release metadata and changelog entry used by the automated release workflow.

Comment thread lib/posthog/config.ex Outdated

@compiled_configuration_schema NimbleOptions.new!(@configuration_schema)
@compiled_convenience_schema NimbleOptions.new!(@convenience_schema)

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

nit: Format the changed files — these whitespace-only lines and the copied indentation in config_schema.ex fail the formatter check. Please run mix format lib/posthog/config.ex lib/posthog/config_schema.ex. Reproduction: reproduced — mix format --check-formatted lib/posthog/config.ex lib/posthog/config_schema.ex exits 1 and identifies both files as unformatted.

Comment thread lib/posthog/config.ex Outdated

with {:ok, validated} <-
NimbleOptions.validate(normalized_options, @compiled_configuration_schema) do
NimbleOptions.validate(normalized_options, PostHog.Config.Schema.configuration()) do

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

nit: Alias the schema module — the repeated fully qualified PostHog.Config.Schema calls introduce four Credo alias warnings, so strict Credo also fails independently of formatting. Please use a module alias for these calls. Reproduction: reproduced — MIX_ENV=test mix credo --strict exits 6 with four alias warnings on the reviewed head, while the same command passes at the merge-base.

@marandaneto

Copy link
Copy Markdown
Member

Commits must have verified signatures.

your commits need to be signed

@marandaneto
marandaneto requested a review from a team October 5, 2026 09:10
@boxxxie
boxxxie force-pushed the fix/elixir-1.18-reference-bug branch from d1ead19 to c655a95 Compare October 5, 2026 09:21
@boxxxie

boxxxie commented Oct 5, 2026

Copy link
Copy Markdown
Contributor Author

I've squashed the commits, signed them, and added a changeset file.

@boxxxie

boxxxie commented Oct 5, 2026

Copy link
Copy Markdown
Contributor Author

sorry, i haven't setup my GPG key. i'm doing that now

This commit also includes a changeset.
@boxxxie
boxxxie force-pushed the fix/elixir-1.18-reference-bug branch from c655a95 to f5dc8c6 Compare October 5, 2026 12:34
@boxxxie

boxxxie commented Oct 5, 2026

Copy link
Copy Markdown
Contributor Author

ok, hope that everything is good now.

@dustinbyrne dustinbyrne left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

looks great! thank you @boxxxie!

@dustinbyrne
dustinbyrne merged commit aea1877 into PostHog:main Oct 6, 2026
29 checks passed
@boxxxie

boxxxie commented Oct 7, 2026

Copy link
Copy Markdown
Contributor Author

thanks a lot for being quick to release. i'm using the new version now.

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