-
Notifications
You must be signed in to change notification settings - Fork 27
Implicit import check during target validation #130
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
a3223c0 to
3accf7a
Compare
Signed-off-by: Ryan Levick <ryan.levick@fermyon.com>
3accf7a to
3fb7ef4
Compare
|
Thanks for digging into this! I haven't extensively studied the code just yet but I did try out the changes with the following example: I have a component called And this When running Thanks again for tackling this; could you add a test or two when you get a chance? |
Signed-off-by: Ryan Levick <ryan.levick@fermyon.com>
|
@fibonacci1729 thanks for finding the issue! It turns out we were always assuming a 1 to 1 correspondence between an import node (i.e., a node in the wac graph) and the item we wanted to type check. However, implicit imports don't have nodes in the wac graph (that's what makes them implicit after all!). The latest change more directly provides the I think this should fix the issue you're seeing - in my testing I got errors that made much more sense and correctly identified where the component and the target world didn't line up. I'll look into how we can add tests for this. |
Signed-off-by: Ryan Levick <ryan.levick@fermyon.com>
|
I looked into adding a test, and discovered a new issue I'd like to address first. The issue is that just like wac, wit sort of has a similar concept of implicit imports. If you use an item inside of an imported interface from another interface, that other interface will be implicitly imported. I'll need to do the work of looking up interfaces through used items as well as direct imports. |
Signed-off-by: Ryan Levick <ryan.levick@fermyon.com>
|
I've addressed the issue of interfaces implicitly imported through uses and the test I've added now passes. I believe this is ready for final review and merge. |
Signed-off-by: Ryan Levick <ryan.levick@fermyon.com>
|
Awesome work @rylev! I'll give this a review and test on monday. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Great work @rylev ! The code looks great (very understandable) and the manual tests i was running now pass.
From my example earlier, i now see:
× target world `wasi:http/proxy@0.2.0` does not have an import named `fermyon:spin/key-value@2.0.0`
... which is exactly how I expect it to fail.
[](https://renovatebot.com) This PR contains the following updates: | Package | Type | Update | Change | |---|---|---|---| | [wac-graph](https://togithub.com/bytecodealliance/wac) | workspace.dependencies | minor | `0.3.0` -> `0.4.0` | --- ### Release Notes <details> <summary>bytecodealliance/wac (wac-graph)</summary> ### [`v0.4.0`](https://togithub.com/bytecodealliance/wac/releases/tag/v0.4.0) [Compare Source](https://togithub.com/bytecodealliance/wac/compare/v0.3.0...v0.4.0) #### What's Changed - docs: more generic command listing prose by [@​vados-cosmonic](https://togithub.com/vados-cosmonic) in [https://github.com/bytecodealliance/wac/pull/125](https://togithub.com/bytecodealliance/wac/pull/125) - Bump h2 from 0.4.3 to 0.4.5 by [@​dependabot](https://togithub.com/dependabot) in [https://github.com/bytecodealliance/wac/pull/126](https://togithub.com/bytecodealliance/wac/pull/126) - Update semver regex to not swallow trailing `.` by [@​itowlson](https://togithub.com/itowlson) in [https://github.com/bytecodealliance/wac/pull/129](https://togithub.com/bytecodealliance/wac/pull/129) - Implicit import check during target validation by [@​rylev](https://togithub.com/rylev) in [https://github.com/bytecodealliance/wac/pull/130](https://togithub.com/bytecodealliance/wac/pull/130) #### New Contributors - [@​vados-cosmonic](https://togithub.com/vados-cosmonic) made their first contribution in [https://github.com/bytecodealliance/wac/pull/125](https://togithub.com/bytecodealliance/wac/pull/125) - [@​dependabot](https://togithub.com/dependabot) made their first contribution in [https://github.com/bytecodealliance/wac/pull/126](https://togithub.com/bytecodealliance/wac/pull/126) - [@​itowlson](https://togithub.com/itowlson) made their first contribution in [https://github.com/bytecodealliance/wac/pull/129](https://togithub.com/bytecodealliance/wac/pull/129) **Full Changelog**: bytecodealliance/wac@v0.3.0...v0.4.0 </details> --- ### Configuration 📅 **Schedule**: Branch creation - At any time (no schedule defined), Automerge - At any time (no schedule defined). 🚦 **Automerge**: Disabled by config. Please merge this manually once you are satisfied. ♻ **Rebasing**: Whenever PR becomes conflicted, or you tick the rebase/retry checkbox. 🔕 **Ignore**: Close this PR and you won't be reminded about this update again. --- - [ ] If you want to rebase/retry this PR, check this box --- This PR has been generated by [Mend Renovate](https://www.mend.io/free-developer-tools/renovate/). View repository job log [here](https://developer.mend.io/github/andrzejressel/pulumi-wasm).
Fixes #127
When performing target validation (i.e., whether a component graph represents a component that matches the given world), we were just iterating the explicit imports. Now, we iterate all imports both implicit and explicit.
This PR also contains a slight refactoring of
encode_importsthat isn't necessary but came from an early exploration and which I think makes the code more readable. Let me know if I should remove this.When an implicit import is the cause of a validation error, the error message isn't wonderful since we don't have a span to point to like we do in the explicit import case. I think we can land this though before we figure out exactly how to improve the error message.