Comments (20)
No way, I'm on the playground 😅
from regal.
I was setting it up but seems like the problems tab started working finally. (very new with OPA-Rego)
Thank you so much I do guess (if in a few days i dont drop by this bug is for real solved)
Thank you :)
from regal.
No, no admin permissions needed 🙂 Thank you for all the details provided! I'm still not sure what would cause this, and I don't have a windows machine at hand, but I'll try my best to see if I can reproduce this in some way. I'll keep you posted!
from regal.
Lol, alright! I'll need a reviewer anyway, so let's push it out tomorrow.
from regal.
That’s fine. We don’t support that method yet, so we log that when we receive a request for that. It shouldn’t have any impact on server operations though. Are things working? But config file ignored?
from regal.
Hi there @scoop96! And thanks for filing an issue, although I obviously wish you didn't have to 🙂
The trace you provided (thanks for that too!) suggests the issue is encountered when Regal traverses your directory tree looking for a config file:
// Move up one level in the directory tree
parts := strings.Split(dir, rio.PathSeparator)
parts = parts[:len(parts)-1] // <-- referencing index 0 in an empty slice here which causes the panic
I'm not sure why this would happen, but at least it's obvious where it happens. The docs for strings.Split
says:
Split slices s into all substrings separated by sep and returns a slice of the substrings between those separators.
If s does not contain sep and sep is not empty, Split returns a slice of length 1 whose only element is s.
If sep is empty, Split splits after each UTF-8 sequence. If both s and sep are empty, Split returns an empty slice.
The second argument here comes from os.PathSeparator
and that should never be empty. It's not documented above, but it seems like strings.Split("", "\\")
also returns an empty slice, which is likely what's happening here. I'll try and fix that.
In the meantime, do you have a Regal config file in your project workspace? I suppose that if Regal finds one, it won't keep searching, which could be a workaround in the meantime. Just create a .regal/config.yaml
file in your project root directory, and put something in there: https://github.com/styraInc/regal?tab=readme-ov-file#configuration
Let me know if that helps work around the issue for the time being.
from regal.
Btw, @scoop96, what does the path to your workspace look like? Just curious if there's anything in that (like special characters, whitespace, etc) that could cause issues here.
from regal.
First i started without config file, after so i added a config file (default one as indicated here in de official doc)
Im adding it again by default, allow me to clean something and I'll show you the workspace directory
from regal.
Did adding a config file help stop the server from crashing?
Just to clarify, I don't need to know what your workspace looks like, only what the path to the workspace looks like. I.e. something like C:\Foo\Bar\Baz
from regal.
And as indicated in the origin, opa and regal are inside of /Users/SE99236/
from regal.
Did adding a config file help stop the server from crashing?
Just to clarify, I don't need to know what your workspace looks like, only what the path to the workspace looks like. I.e. something like
C:\Foo\Bar\Baz
Nope, its still the same output
from regal.
In my OS, we need to ask for a superior team to give us admin permissions.
Does the OPA extension need them? in order to do that configuration manually myself.
Cybersecurity things :)
from regal.
After the commit, i updated the .exe and the issue still on, same thing.
from regal.
Did you build Regal yourself? If not, you'll have to get the v0.21.2 release from here: https://github.com/StyraInc/regal/releases/tag/v0.21.2
from regal.
The first download was wrong, after using the v0.21.2 the error still on, that is odd am i right?
In the new error the comment Server process exited with code 2.
its in a different possition
panic: runtime error: index out of range [0] with length 0
goroutine 35 [running]:
github.com/styrainc/regal/pkg/config.FindRegalDirectory({0xc0004025a1, 0x1d})
/home/runner/work/regal/regal/pkg/config/config.go:144 +0x497
github.com/styrainc/regal/pkg/config.FindConfig({0xc0004025a1?, 0xc0004281e0?})
/home/runner/work/regal/regal/pkg/config/config.go:153 +0x1c
github.com/styrainc/regal/internal/lsp.(*LanguageServer).handleInitialize(0xc00011ce00, {0x140?, 0x9a2220?}, 0xc00018e3b0?, 0xc00041e000)
/home/runner/work/regal/regal/internal/lsp/server.go:1024 +0x517
github.com/styrainc/regal/internal/lsp.(*LanguageServer).Handle(0xc00011ce00, {0xf6f388, 0xc00037ce60}, 0xc0000db320, 0xc00041e000)
/home/runner/work/regal/regal/internal/lsp/server.go:102 +0x191
github.com/sourcegraph/jsonrpc2.(*HandlerWithErrorConfigurer).Handle(0xc00038a1e0, {0xf6f388, 0xc00037ce60}, 0xc0000db320, 0xc00041e000)
/home/runner/go/pkg/mod/github.com/sourcegraph/[email protected]/handler_with_error.go:21 +0x57
github.com/sourcegraph/jsonrpc2.(*Conn).readMessages(0xc0000db320, {0xf6f388, 0xc00037ce60})
/home/runner/go/pkg/mod/github.com/sourcegraph/[email protected]/conn.go:205 +0x2dd
created by github.com/sourcegraph/jsonrpc2.NewConn in goroutine 1
/home/runner/go/pkg/mod/github.com/sourcegraph/[email protected]/conn.go:62 +0x1e6
[Error - 4:50:08 PM] Server process exited with code 2.
[Error - 4:50:08 PM] Server initialization failed.
Message: Pending response rejected since connection got disposed
Code: -32097
[Error - 4:50:08 PM] Connection to server got closed. Server will not be restarted.
[Error - 4:50:08 PM] Regal LSP client client: couldn't create connection to server.
Message: Pending response rejected since connection got disposed
Code: -32097
from regal.
Hmm yeah. I'll need a Windows machine to test this on. I'll get back to you when I have that!
from regal.
The added check wasn't enough. We'd need to error out if the length is not greater than 1. It's len=1 here, then we drop a segment, it's empty, and accessing the first element panicks...
from regal.
@srenatus yep, that's what we get for patching without being able to test properly, I suppose 🤦
Do you have time to submit a fix? I'm in meetings for the next 2 hours. I'll get another patch release out later tonight.
from regal.
@scoop96 can you try v0.21.3? It'll likely won't find your config (but if it does, let me know!) but at least it shouldn't panic.
from regal.
@anderseknert This is the new error output:
2024/04/29 08:46:00 jsonrpc2 handler: notification "$/setTrace" handling error: jsonrpc2: code -32601 message: method not supported: $/setTrace
from regal.
Related Issues (20)
- Completions: rule head (if, contains, etc) improvements
- CI: See if we can use caching to avoid downloading rq over and over HOT 1
- Be specific about number of errors vs warnings in `regal lint` summary
- Rule: `if-object-literal` HOT 1
- Rule: `var-shadows-builtin`
- Not all folding ranges shown in Zed editor HOT 1
- Code completion in comments (Zed) HOT 2
- Zed doesn't render markdown tables
- Send message to client when outdated Regal is detected
- Completions: `if` and `contains` should not be suggested following import
- Completions: avoid suggesting recursive function call
- Completions: suggest known object keys for certain built-in functions
- Completions: provide suggestions of rules and functions in file following `default` keyword
- Allow using `regal fix` as a formatter
- POC: embedding compiler state for `regal lint` command
- Completion suggestions should not contain duplicates
- Suggest local variables as arguments to function call
- Improve package name suggestion based on directory path
- False positive in `top-level-iteration` when using ref head rules
- Completions: package name suggestion should never be an empty string
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from regal.