{"record":{"id":"8af388890cf3f1e6","repo":"ory/hydra","slug":"errnoprocesspool","errorCode":"ErrNoProcessPool","errorMessage":"jsonnetsecure: a process pool is required; use MakeInProcessVM to evaluate in this process without isolation","messagePattern":"jsonnetsecure: a process pool is required; use MakeInProcessVM to evaluate in this process without isolation","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"oryx/jsonnetsecure/jsonnet.go","lineNumber":83,"sourceCode":"\t}\n}\n\nfunc WithJsonnetBinary(jsonnetBinaryPath string) Option {\n\treturn func(o *vmOptions) {\n\t\to.jsonnetBinaryPath = jsonnetBinaryPath\n\t}\n}\n\nfunc WithProcessArgs(args ...string) Option {\n\treturn func(o *vmOptions) {\n\t\to.args = args\n\t}\n}\n\n// ErrNoProcessPool is returned by MakeSecureVM when called without a process\n// pool. It is a distinct error because the alternative — quietly returning an\n// in-process VM — would strip the isolation callers of this package rely on.\nvar ErrNoProcessPool = errors.New(\"jsonnetsecure: a process pool is required; use MakeInProcessVM to evaluate in this process without isolation\")\n\n// MakeSecureVM returns a VM that evaluates snippets in a worker process taken\n// from p, so that a snippet which exhausts memory, spins on the CPU, or crashes\n// takes down only that worker.\n//\n// p is a required argument rather than an option because a VM without a pool\n// offers no isolation at all. Passing a nil pool returns ErrNoProcessPool.\nfunc MakeSecureVM(p Pool, opts ...Option) (VM, error) {\n\t// A nil *pool inside a non-nil Pool interface is not reachable from outside\n\t// this package (Pool has an unexported method), but check the concrete\n\t// value anyway so a future in-package mistake cannot slip through.\n\tconcrete, _ := p.(*pool)\n\tif p == nil || concrete == nil {\n\t\treturn nil, errors.WithStack(ErrNoProcessPool)\n\t}\n\n\toptions := newVMOptions()\n\tfor _, o := range opts {","sourceCodeStart":65,"sourceCodeEnd":101,"githubUrl":"https://github.com/ory/hydra/blob/4174065ffb052799890f7480f5360a877a67ffc1/oryx/jsonnetsecure/jsonnet.go#L65-L101","documentation":"MakeSecureVM (oryx/jsonnetsecure/jsonnet.go:83, raised at :97) requires a non-nil Pool so Jsonnet snippets evaluate in an isolated worker process. It deliberately refuses to fall back to an in-process VM, because silently losing process isolation would let a malicious or memory-hungry snippet take down the caller's process. ErrNoProcessPool is a sentinel (use errors.Is to detect it).","triggerScenarios":"Calling jsonnetsecure.MakeSecureVM(nil) or MakeSecureVM(p) where p is a nil *pool stored in a non-nil Pool interface (typed-nil), e.g. a struct field of type Pool that was never initialized with NewProcessPool.","commonSituations":"Constructing the VM before the pool is created or after pool initialization was skipped in tests; a typed-nil interface (var p *pool; MakeSecureVM(p) via an interface variable); refactoring that removed pool wiring from dependency injection.","solutions":["Create the pool first: pool := jsonnetsecure.NewProcessPool(size), then vm, err := jsonnetsecure.MakeSecureVM(pool).","Check for typed-nil: ensure the Pool variable actually holds a *pool from NewProcessPool, not a nil pointer stored in an interface.","If you truly do not need isolation (trusted input, CLI tooling), switch to jsonnetsecure.MakeInProcessVM() as the error message suggests.","Guard construction order so the pool outlives the VM and is non-nil at VM creation."],"exampleFix":"// before\nvar pool jsonnetsecure.Pool // nil\nvm, err := jsonnetsecure.MakeSecureVM(pool) // ErrNoProcessPool\n\n// after\npool := jsonnetsecure.NewProcessPool(10)\ndefer pool.Close()\nvm, err := jsonnetsecure.MakeSecureVM(pool)","handlingStrategy":"type-guard","validationCode":"if pool == nil || reflect.ValueOf(pool).Kind() == reflect.Ptr && reflect.ValueOf(pool).IsNil() {\n    pool = jsonnetsecure.NewProcessPool(defaultSize)\n}\nvm, err := jsonnetsecure.MakeSecureVM(pool)","typeGuard":"func poolReady(p jsonnetsecure.Pool) bool {\n    return p != nil && reflect.ValueOf(p).Kind() == reflect.Ptr && !reflect.ValueOf(p).IsNil()\n}","tryCatchPattern":"vm, err := jsonnetsecure.MakeSecureVM(pool)\nif err != nil {\n    if errors.Is(err, jsonnetsecure.ErrNoProcessPool) {\n        // re-create pool or fall back to MakeInProcessVM for trusted input only\n    }\n    return err\n}","preventionTips":["Initialize the pool in the same constructor that builds the VM.","Never declare Pool-typed variables without assigning NewProcessPool output (avoids typed-nil).","For trusted/CLI contexts, prefer MakeInProcessVM explicitly instead of passing nil.","Add a startup assertion that the pool is non-nil before wiring dependent components."],"tags":["jsonnet","process-isolation","nil-argument","api-misuse"],"backgroundTag":"missing-process-pool","analyzedSha":"4174065ffb052799890f7480f5360a877a67ffc1","analyzedAt":"2026-09-03T14:52:41.581Z","contentChangedAt":"2026-09-03T14:52:41.581Z","schemaVersion":2},"datasetVersion":"2026-09-10T17:17:09.494Z"}