SpiceDb
SpiceDb copied to clipboard
`StartIndex cannot be less than zero` when importing schema from string or file
Hello, when running dotnet test (or trying to import my own schema from a file), I get this error:
System.ArgumentOutOfRangeException: StartIndex cannot be less than zero. (Parameter 'startIndex')
at System.String.ThrowSubstringArgumentOutOfRange(Int32 startIndex, Int32 length)
at System.String.Substring(Int32 startIndex)
at SpiceDb.Api.SchemaParser.Parse(String schema)
at SpiceDb.SpiceDbClient.ImportSchemaFromStringAsync(String schema)
This is on M1 macOS Sonoma 14.1.1, .NET 7, SpiceDb 1.4.1. I'll clone the repo tonight and see if I can provide more details for you. Thanks!
The schema code is mostly all from SpiceDB.Hierarchical.UI. It's not super pretty and feels bolted on. If you uncover the issue let me know. I usually do schema stuff via command line.
Just an update, this is the current error with 1.38.x using client.ImportSchemaFromFileAsync("./schema.zed"). I'm just forking out to the CLI from within my app in the meantime.
---> System.AggregateException: One or more errors occurred. (Index was outside the bounds of the array.)
---> System.IndexOutOfRangeException: Index was outside the bounds of the array.
at SpiceDb.Api.SchemaParser.ReadPermissions(String txt, SchemaEntity entity)
at SpiceDb.Api.SchemaParser.ParseEntity(Int32 _index, String text)
at SpiceDb.Api.SchemaParser.Parse(String schema)
at SpiceDb.SpiceDbClient.ImportSchemaFromStringAsync(String schema)
at SpiceDb.SpiceDbClient.ImportSchemaFromFileAsync(String filePath)
There is a ReadSchema and WriteSchema method. Have you tried those?