Skip to content

Verify Metadata Struct Fields after Compilation#217

Merged
zachdaniel merged 1 commit intoash-project:mainfrom
maennchen:jm/meta_check_verify
Sep 25, 2025
Merged

Verify Metadata Struct Fields after Compilation#217
zachdaniel merged 1 commit intoash-project:mainfrom
maennchen:jm/meta_check_verify

Conversation

@maennchen
Copy link
Copy Markdown
Contributor

@maennchen maennchen commented Sep 25, 2025

Fixes

https://discord.com/channels/711271361523351632/1037049265836535868/1420674638622752788

== Compilation error in file lib/ash_authentication/strategies/magic_link.ex ==
** (UndefinedFunctionError) function AshAuthentication.Strategy.MagicLink.__struct__/0 is undefined (function not available)
    AshAuthentication.Strategy.MagicLink.__struct__()
    /Users/.../code/kloevaa/deps/spark/lib/spark/dsl/extension.ex:1515: (module)
    (spark 2.3.3) lib/spark/dsl/extension.ex:1253: Spark.Dsl.Extension.build_entity/8
could not compile dependency :ash_authentication, "mix compile" failed. Errors may have been logged above. You can recompile this dependency with "mix deps.compile ash_authentication --force", update it with "mix deps.update ash_authentication" or clean it with "mix deps.clean ash_authentication"

The issue is that the struct module may not be fully compiled when checking and in that case, the __struct__/0 function does not yet exist. Moving the check into after_verify.

Tests

This does not contain a test. I don't know how I would test this without starting a Parallel Compiler and having a circular dependency. And that would probably mean running a full small fixture mix project.

Contributor checklist

Leave anything that you believe does not apply unchecked.

  • I accept the AI Policy, or AI was not used in the creation of this PR.
  • Bug fixes include regression tests
  • Chores
  • Documentation changes
  • Features include unit/acceptance tests
  • Refactoring
  • Update dependencies

Copy link
Copy Markdown
Contributor

@zachdaniel zachdaniel left a comment

Choose a reason for hiding this comment

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

One thing to note (and I think this was already the case from my impl) is that this doesn't check nested entities (entities inside entities).

@zachdaniel zachdaniel merged commit 93c527d into ash-project:main Sep 25, 2025
21 of 22 checks passed
@maennchen maennchen deleted the jm/meta_check_verify branch September 25, 2025 12:05
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.

2 participants