-
Notifications
You must be signed in to change notification settings - Fork 12
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix: Show error message for unregistered type name (#594)
Check and throw the error for the `expose` function when called from the Python SDK. #### Motivation and context We got a finalization failure when there are some unregistered type referenced with `g.ref`. #### Migration notes _No changes needed._ ### Checklist - [x] The change come with new or modified tests - [x] Hard-to-understand functions have explanatory comments - [x] End-user documentation is updated to reflect the change
- Loading branch information
Showing
3 changed files
with
31 additions
and
1 deletion.
There are no files selected for viewing
12 changes: 12 additions & 0 deletions
12
typegate/tests/regression/invalid_ref_error_message/invalid_ref.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
from typegraph import typegraph, Graph, Policy, t | ||
from typegraph.runtimes import DenoRuntime | ||
|
||
|
||
@typegraph() | ||
def invalid_ref(g: Graph): | ||
public = Policy.public() | ||
deno = DenoRuntime() | ||
|
||
user = t.struct({"id": t.uuid(), "posts": t.list(g.ref("Post"))}) | ||
|
||
g.expose(public, user=deno.identity(user)) |
15 changes: 15 additions & 0 deletions
15
typegate/tests/regression/invalid_ref_error_message/invalid_ref_test.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
// Copyright Metatype OÜ, licensed under the Elastic License 2.0. | ||
// SPDX-License-Identifier: Elastic-2.0 | ||
|
||
import { Meta } from "test-utils/mod.ts"; | ||
import { assertRejects } from "std/assert/mod.ts"; | ||
|
||
Meta.test("invalid ref", async (t) => { | ||
await assertRejects( | ||
() => | ||
t.engine( | ||
"regression/invalid_ref_error_message/invalid_ref.py", | ||
), | ||
"type name 'Post' has not been registered", | ||
); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters