mirror of
https://github.com/go-delve/delve.git
synced 2025-11-03 05:47:34 +08:00
service/dap: validate the client configurations in initialize request (#2435)
The client can specify certain configurations in the initialize request. For example, pathFormat determines the pathFormat. We do not currently support configuring pathFormat, linesStartAt1, or columnsStartAt1, so we report an error if the client attempts to set these to an unsupported value.
This commit is contained in:
@ -608,6 +608,22 @@ func (s *Server) logToConsole(msg string) {
|
||||
}
|
||||
|
||||
func (s *Server) onInitializeRequest(request *dap.InitializeRequest) {
|
||||
if request.Arguments.PathFormat != "path" {
|
||||
s.sendErrorResponse(request.Request, FailedToInitialize, "Failed to initialize",
|
||||
fmt.Sprintf("Unsupported 'pathFormat' value '%s'.", request.Arguments.PathFormat))
|
||||
return
|
||||
}
|
||||
if !request.Arguments.LinesStartAt1 {
|
||||
s.sendErrorResponse(request.Request, FailedToInitialize, "Failed to initialize",
|
||||
"Only 1-based line numbers are supported.")
|
||||
return
|
||||
}
|
||||
if !request.Arguments.ColumnsStartAt1 {
|
||||
s.sendErrorResponse(request.Request, FailedToInitialize, "Failed to initialize",
|
||||
"Only 1-based column numbers are supported.")
|
||||
return
|
||||
}
|
||||
|
||||
// TODO(polina): Respond with an error if debug session is in progress?
|
||||
response := &dap.InitializeResponse{Response: *newResponse(request.Request)}
|
||||
response.Body.SupportsConfigurationDoneRequest = true
|
||||
|
||||
Reference in New Issue
Block a user