Skip to content

lsp/eval: Ensure filenames use URI in print output#1647

Merged
charlieegan3 merged 1 commit intoopen-policy-agent:mainfrom
charlieegan3:print-hook-file-name-base
Aug 7, 2025
Merged

lsp/eval: Ensure filenames use URI in print output#1647
charlieegan3 merged 1 commit intoopen-policy-agent:mainfrom
charlieegan3:print-hook-file-name-base

Conversation

@charlieegan3
Copy link
Contributor

This is a regression fix from #1638 which caused the print output to not be rendered in supported clients.

Fixes open-policy-agent/vscode-opa#352

h.Output[ctx.Location.File] = make(map[int][]string)
filename := ctx.Location.File
if h.FileNameBase != "" {
filename = strings.TrimSuffix(h.FileNameBase, "/") + "/" + ctx.Location.File
Copy link
Member

Choose a reason for hiding this comment

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

Can use util.EnsureSuffix here. Added recently :)

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Ahh yeah, nearly remembered that! next time!

policy2URI: {
4: {"1"},
},
}
Copy link
Member

Choose a reason for hiding this comment

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

Does this one item map really warrant 5 lines? lol

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Fixed now!

},
}

if diff := cmp.Diff(expectedPrintOutput, res.PrintOutput); diff != "" {
Copy link
Member

Choose a reason for hiding this comment

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

Nice I didn't know about cmp.Diff

Copy link
Contributor Author

Choose a reason for hiding this comment

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

it's pretty good, used it in OPA earlier too.

This is a regression fix from open-policy-agent#1638
which caused the print output to not be rendered in supported clients.

Fixes open-policy-agent/vscode-opa#352

Signed-off-by: Charlie Egan <charlie@styra.com>
@charlieegan3 charlieegan3 force-pushed the print-hook-file-name-base branch from 6690819 to 3514082 Compare August 7, 2025 15:46
@charlieegan3 charlieegan3 merged commit d1fca9a into open-policy-agent:main Aug 7, 2025
6 checks passed
@charlieegan3 charlieegan3 deleted the print-hook-file-name-base branch August 7, 2025 15:50
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.

Output of print calls no longer displayed inline by Evaluate command

2 participants