Skip to content

Reproduce (KeyError) key :to_tenant not found in: nil#309

Merged
zachdaniel merged 1 commit intoash-project:mainfrom
moxley:moxley/error-to-tenant
May 6, 2025
Merged

Reproduce (KeyError) key :to_tenant not found in: nil#309
zachdaniel merged 1 commit intoash-project:mainfrom
moxley:moxley/error-to-tenant

Conversation

@moxley
Copy link
Copy Markdown
Contributor

@moxley moxley commented May 5, 2025

Contributor checklist

  • Bug fixes include regression tests
  • Features include unit/acceptance tests

Elixir Forum reference: https://elixirforum.com/t/not-found-in-nil-exception-after-ash-upgrade/70722/15

15:17:28.414 [error] 4291beb8-4a54-4fb1-b9bd-cdd57dba42b1: Exception raised while resolving query.

** (Ash.Error.Unknown) 
Bread Crumbs:
  > Exception raised in: GF.Event.read> Exception raised in: GF.Attendee.read

Unknown Error

* ** (KeyError) key :to_tenant not found in: nil

If you are using the dot syntax, such as map.field, make sure the left-hand side of the dot is a map
  (ash 3.5.8) lib/ash/policy/check/expression.ex:3: Ash.Policy.Check.Expression.try_strict_check/3
  (ash 3.5.8) lib/ash/policy/policy.ex:183: Ash.Policy.Policy.fetch_or_strict_check_fact/2
  (ash 3.5.8) lib/ash/policy/policy.ex:431: Ash.Policy.Policy.handle_constants/2
  (ash 3.5.8) lib/ash/policy/policy.ex:404: Ash.Policy.Policy.handle_constants/2
  (ash 3.5.8) lib/ash/policy/policy.ex:390: Ash.Policy.Policy.handle_constants/2
  (ash 3.5.8) lib/ash/policy/policy.ex:404: Ash.Policy.Policy.handle_constants/2
  (ash 3.5.8) lib/ash/policy/policy.ex:390: Ash.Policy.Policy.handle_constants/2
  (ash 3.5.8) lib/ash/policy/policy.ex:29: Ash.Policy.Policy.solve/1
  (ash 3.5.8) lib/ash/policy/checker.ex:65: Ash.Policy.Checker.strict_check_scenarios/1
  (ash 3.5.8) lib/ash/policy/authorizer/authorizer.ex:1696: Ash.Policy.Authorizer.strict_check_result/2
  (ash 3.5.8) lib/ash/policy/authorizer/authorizer.ex:1119: Ash.Policy.Authorizer.field_condition/5
  (ash 3.5.8) lib/ash/policy/authorizer/authorizer.ex:1082: Ash.Policy.Authorizer.expression_for_ref/6
  (ash 3.5.8) lib/ash/policy/authorizer/authorizer.ex:1006: Ash.Policy.Authorizer.replace_refs/2
  (ash 3.5.8) lib/ash/policy/authorizer/authorizer.ex:972: Ash.Policy.Authorizer.replace_refs/2
  (ash 3.5.8) lib/ash/policy/authorizer/authorizer.ex:734: Ash.Policy.Authorizer.alter_filter/3
  (ash 3.5.8) lib/ash/can.ex:481: Ash.Can.alter_query/5
  (elixir 1.18.1) lib/enum.ex:2546: Enum."-reduce/3-lists^foldl/2-0-"/3
  (ash 3.5.8) lib/ash.ex:1390: Ash.can/3
  (ash 3.5.8) lib/ash/actions/read/read.ex:1415: Ash.Actions.Read.authorize_query/2
  (ash 3.5.8) lib/ash/actions/read/read.ex:472: Ash.Actions.Read.do_read/5

    (ash 3.5.8) lib/ash/policy/check/expression.ex:3: Ash.Policy.Check.Expression.try_strict_check/3
    (ash 3.5.8) lib/ash/policy/policy.ex:183: Ash.Policy.Policy.fetch_or_strict_check_fact/2
    (ash 3.5.8) lib/ash/policy/policy.ex:431: Ash.Policy.Policy.handle_constants/2
    (ash 3.5.8) lib/ash/policy/policy.ex:404: Ash.Policy.Policy.handle_constants/2
    (ash 3.5.8) lib/ash/policy/policy.ex:390: Ash.Policy.Policy.handle_constants/2
    (ash 3.5.8) lib/ash/policy/policy.ex:404: Ash.Policy.Policy.handle_constants/2
    (ash 3.5.8) lib/ash/policy/policy.ex:390: Ash.Policy.Policy.handle_constants/2
    (ash 3.5.8) lib/ash/policy/policy.ex:29: Ash.Policy.Policy.solve/1
    (ash 3.5.8) lib/ash/policy/checker.ex:65: Ash.Policy.Checker.strict_check_scenarios/1
    (ash 3.5.8) lib/ash/policy/authorizer/authorizer.ex:1696: Ash.Policy.Authorizer.strict_check_result/2
    (ash 3.5.8) lib/ash/policy/authorizer/authorizer.ex:1119: Ash.Policy.Authorizer.field_condition/5
    (ash 3.5.8) lib/ash/policy/authorizer/authorizer.ex:1082: Ash.Policy.Authorizer.expression_for_ref/6
    (ash 3.5.8) lib/ash/policy/authorizer/authorizer.ex:1006: Ash.Policy.Authorizer.replace_refs/2
    (ash 3.5.8) lib/ash/policy/authorizer/authorizer.ex:972: Ash.Policy.Authorizer.replace_refs/2
    (ash 3.5.8) lib/ash/policy/authorizer/authorizer.ex:734: Ash.Policy.Authorizer.alter_filter/3
    (ash 3.5.8) lib/ash/can.ex:481: Ash.Can.alter_query/5
    (elixir 1.18.1) lib/enum.ex:2546: Enum."-reduce/3-lists^foldl/2-0-"/3
    (ash 3.5.8) lib/ash.ex:1390: Ash.can/3
    (ash 3.5.8) lib/ash/actions/read/read.ex:1415: Ash.Actions.Read.authorize_query/2
    (ash 3.5.8) lib/ash/actions/read/read.ex:472: Ash.Actions.Read.do_read/5




  1) test basic (GF.Test)
     test/gf_test.exs:4
     Expected truthy, got nil
     code: assert data["getEvent"]
     arguments:

         # 1
         %{"getEvent" => nil}

         # 2
         "getEvent"

     stacktrace:
       test/gf_test.exs:73: (test)

@zachdaniel
Copy link
Copy Markdown
Contributor

🚀 Thank you for your contribution! 🚀

@zachdaniel zachdaniel merged commit 5164f64 into ash-project:main May 6, 2025
16 of 18 checks passed
@moxley moxley deleted the moxley/error-to-tenant branch May 6, 2025 23:24
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