Skip to content

Commit

Permalink
fix(code): do NOT compile single code protocol w/o `request.SelfCon…
Browse files Browse the repository at this point in the history
…tained`

Signed-off-by: Dwi Siswanto <[email protected]>
  • Loading branch information
dwisiswant0 committed Oct 21, 2024
1 parent e945ac1 commit 9811d31
Showing 1 changed file with 9 additions and 1 deletion.
10 changes: 9 additions & 1 deletion pkg/protocols/code/code.go
Original file line number Diff line number Diff line change
Expand Up @@ -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"`
Expand All @@ -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:"-"`
Expand Down Expand Up @@ -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
}

Expand Down

0 comments on commit 9811d31

Please sign in to comment.