vscode-opa icon indicating copy to clipboard operation
vscode-opa copied to clipboard

Evaluate and debug generates different results while have data usage in regal

Open suda1218 opened this issue 11 months ago • 7 comments

image

As above, "evaluate" generates false, while the actual result is true image

suda1218 avatar Jan 16 '25 07:01 suda1218

Hi there!

And thanks for raising this. Regal (and before we had Regal, the VS Code extension calling opa eval) will read relevant files from the workspace in "bundle mode", which means that the location of data.json will determine where in the data tree the data will be placed. If you run the opa eval command with the -b (or --bundle) flag, you should see the same behavior.

I don't think we have an option to disable that in Regal eval currently, but that could of course be an option later. Let me know if that helps!

anderseknert avatar Jan 16 '25 11:01 anderseknert

Thanks for answering! I don't quite get it. Here is my working tree, and I've place my data.json and input.json in the very root place. If I want the debug mode and the eval to have same results, isn't this the right place to go to?

Image

suda1218 avatar Jan 20 '25 02:01 suda1218

What does your .regal/config.yaml look like? Have you configured Regal to ue the bundle directory as a project root?

project:
  roots:
    - bundle

I that's the case, both debug and eval will work relative to that and expect the data.json file to be in the bundle directory too. Does that make sense? If not, let me know, and I can elaborate further.

anderseknert avatar Jan 20 '25 07:01 anderseknert

I tried to configure the root to be bundle, and arranged the location of data.json and input.json. Now they look like:

Image

Image

However, the debugger's eval and opa eval still generates different results:

Image

Strangely, while i stepped into the method, it seems to be going well.

suda1218 avatar Jan 20 '25 09:01 suda1218

Hey! Sorry, I forgot to get back to you on this. Is this still an issue or did you find out what's wrong?

anderseknert avatar Jan 23 '25 15:01 anderseknert

Came across just same issue, evaluation works fine in cli or with vscode under hot key, but doesn't work as "code lens feature". Fix it by adding .manifest file in bundle directory. Take me a while to figuring out what's wrong, doesn't very obviously when you just start usign this fascinating toolkit

pru-mike avatar Mar 22 '25 10:03 pru-mike

Thanks @pru-mike 👍 Definitely high up on my list of priorities to look into this, but it'll most likely have to wait until after KubeCon next week.

anderseknert avatar Mar 24 '25 11:03 anderseknert