Skip to content
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

fix(resolving): detect the source of local references properly #615

Merged
merged 3 commits into from
Oct 2, 2019

Conversation

P0lip
Copy link
Contributor

@P0lip P0lip commented Sep 30, 2019

Fixes #572 (comment) and a potential issue (see 28f8b65)

Checklist

  • Tests added / updated
  • Docs added / updated

Does this PR introduce a breaking change?

  • Yes
  • No

@P0lip P0lip added the t/bug Something isn't working label Sep 30, 2019
@P0lip P0lip self-assigned this Sep 30, 2019
@P0lip
Copy link
Contributor Author

P0lip commented Sep 30, 2019

Hm, some weird issue with bundling 🤔
On it. fixed

Copy link
Contributor

@marbemac marbemac left a comment

Choose a reason for hiding this comment

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

One question, but looks good. Best we can do for now - it's a tricky problem of how to report errors that occur in $ref'd targets.

@@ -48,12 +72,12 @@ export class Resolved {

if (target && target[REF_METADATA]) {
return {
path: [...get(target, [REF_METADATA, 'root'], []), ...newPath],
path: [...get(target, [REF_METADATA, 'root'], []).map(decodePointerFragment), ...newPath],
Copy link
Contributor

Choose a reason for hiding this comment

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

Why is decodePointerFragment required now?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

So the path stored under get(target, [REF_METADATA, 'root'] is escaped, meaning /foo is represented as ~1foo.
The path we expect to return should be unescaped (/foo), so that the YAML/JSON getLocationForJsonPath can find a node correctly.
If you revert the change, the test I added will fail - produced ranges will be less precise (they will point at paths rather than paths//test/get.

@P0lip P0lip merged commit 308369e into develop Oct 2, 2019
@P0lip P0lip deleted the fix/refs-sources branch October 2, 2019 16:14
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
t/bug Something isn't working
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Add {{path}} as option for messages in rulesets
2 participants