Skip to content

fix: refuse a temporal read or write the data layer cannot serve. - #2922

Closed
matt-beanland wants to merge 1 commit into
ash-project:temporalfrom
matt-beanland:temporal-as-of-refused
Closed

fix: refuse a temporal read or write the data layer cannot serve.#2922
matt-beanland wants to merge 1 commit into
ash-project:temporalfrom
matt-beanland:temporal-as-of-refused

Conversation

@matt-beanland

Copy link
Copy Markdown
Contributor

Contributor checklist

  • 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

Summary

The verifier ValidateTemporal requires can?(:temporal, ..) for a given resource to compile, however the checks at runtime are bugged or missing.

This is a PR without an issue as currently temporal data layers must claim can?(:temporal, ..) true otherwise as_of(instant) is silently dropped.

The fix checks the datalayer's capability ahead of all reads and writes, granting the datalayer the ability to safely refuse temporal for instance when the underlying database lacks temporal capability or configuration.

@matt-beanland

Copy link
Copy Markdown
Contributor Author

amended to generalise some comments and error messages

end

# The runtime counterpart of `Ash.Resource.Verifiers.ValidateTemporal`.
defp refuse_unserved_temporal(changeset) do

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.

why do we need a runtime component of this?

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.

How could you get here if the app won't compile otherwise?

@matt-beanland matt-beanland Sep 10, 2026

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Distributed/embedded systems where code compiled on one system and running on another.

Also where db version / temporal capability is runtime configuration or license gated.

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.

Where does that happen in practice? It would mean that all things that we validate at compile time have to also be validated at runtime, which is not a position we hold.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Yes with PG needs PG19 and also btree_gist configuration, allows gate to check. Depends on people's deployment scenarios I guess.

I understand wider implications for other capability checks and that you may prefer to just let the data layer overclaim in this scenario rather than establish a precedent.

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.

Yes but the user configures those things in their repo with min_pg_version and extensions. So we know this information at compile time.

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