Skip to content
This repository has been archived by the owner on Nov 2, 2023. It is now read-only.

Commit

Permalink
agent/backend/signal: do not drop a trace on empty port numbers
Browse files Browse the repository at this point in the history
Avoid dropping an http trace when a port number cannot be parsed.
  • Loading branch information
Julio Guerra authored Aug 31, 2020
2 parents 6b125a5 + df82869 commit 2282ea7
Showing 1 changed file with 5 additions and 9 deletions.
14 changes: 5 additions & 9 deletions internal/backend/api/signal/signal.go
Original file line number Diff line number Diff line change
Expand Up @@ -58,15 +58,11 @@ func NewAgentInfra(agentVersion, osType, hostname, runtimeVersion string) *Agent
}

func fromLegacyRequestRecord(record *legacy_api.RequestRecord, infra *AgentInfra) (*http_trace.Trace, error) {
port, err := strconv.ParseUint(record.Request.Port, 10, 64)
if err != nil {
return nil, sqerrors.Wrap(err, "could not parse the request port number as an uint64 value")
}

remotePort, err := strconv.ParseUint(record.Request.RemotePort, 10, 64)
if err != nil {
return nil, sqerrors.Wrap(err, "could not parse the request remote port number as an uint64 value")
}
// Parse the port numbers by ignoring parsing errors and keeping the default
// zero value otherwise anyway to avoid dropping the the trace for that error.
// For example, the port number can be possibly empty.
port, _ := strconv.ParseUint(record.Request.Port, 10, 64)
remotePort, _ := strconv.ParseUint(record.Request.RemotePort, 10, 64)

headers := make([][]string, len(record.Request.Headers))
for i, e := range record.Request.Headers {
Expand Down

0 comments on commit 2282ea7

Please sign in to comment.