fix(code): do NOT compile single code protocol w/o request.SelfContained

Signed-off-by: Dwi Siswanto <git@dw1.io>
This commit is contained in:
Dwi Siswanto 2024-10-22 05:38:30 +07:00
parent e945ac1e25
commit 9811d31172
No known key found for this signature in database
GPG Key ID: 3BB198907EF44CED

View File

@ -47,7 +47,7 @@ var (
ErrCodeExecutionDeadline = errkit.New("code execution deadline exceeded").SetKind(errkit.ErrKindDeadline).Build()
)
// Request is a request for the SSL protocol
// Request is a request for the code protocol
type Request struct {
// Operators for the current request go here.
operators.Operators `yaml:",inline,omitempty"`
@ -70,6 +70,9 @@ type Request struct {
// description: |
// Source File/Snippet
Source string `yaml:"source,omitempty" json:"source,omitempty" jsonschema:"title=source file/snippet,description=Source snippet"`
// description: |
// SelfContained specifies if the request is self-contained.
SelfContained bool `yaml:"-" json:"-"`
options *protocols.ExecutorOptions `yaml:"-" json:"-"`
preConditionCompiled *goja.Program `yaml:"-" json:"-"`
@ -130,6 +133,11 @@ func (request *Request) Compile(options *protocols.ExecutorOptions) error {
}
request.preConditionCompiled = preConditionCompiled
}
if !request.options.IsMultiProtocol && !request.SelfContained {
return errorutil.NewWithTag(request.TemplateID, "could not compile single %q protocol without enabling self-contained", request.Type())
}
return nil
}