-
Notifications
You must be signed in to change notification settings - Fork 17
Conversation
1330785
to
e5926fc
Compare
@@ -15,7 +15,7 @@ import ( | |||
"github.com/spf13/cobra" | |||
|
|||
_ "github.com/elastic/elastic-agent-libs/logp/configure" | |||
"github.com/elastic/elastic-agent-shipper/server" | |||
"github.com/elastic/elastic-agent-shipper/controller" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I moved controller-related stuff to a separate package to resolve the dependency loop with ./config/config.go
.
In `StrictMode` required fields are: * Timestamp * Datastream.Namespace * Datastream.Dataset * Datastream.Type * Source.InputId
e5926fc
to
b85408e
Compare
Metadata: sampleValues, | ||
Fields: sampleValues, | ||
}, | ||
expectedMsg: "timestamp: proto:\u00a0invalid nil Timestamp", |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
proto:\u00a0invalid
Is the \u00a0
intentional here?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
well, this what the gRPC code returns, I had to include it.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ah, you could use https://pkg.go.dev/google.golang.org/grpc/status#Convert to convert the error to a status object with both the code and message parsed out to avoid this.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ah, you could use https://pkg.go.dev/google.golang.org/grpc/status#Convert to convert the error to a status object with both the code and message parsed out to avoid this.
@cmacknz By code
I meant "source code", I don't know why but sometimes it's returned with this character, sometimes it is not. The weird thing is that it does not seem to be flaky when I run tests.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ah I misinterpreted. Convert
or FromError
are fine, I missed that it was already used.
The Unicode character is a non-breaking space and it is coming from this code that appears to be deliberately randomizing the returned error string: https://github.com/protocolbuffers/protobuf-go/blob/fb0abd915897428ccfdd6b03b48ad8219751ee54/internal/errors/errors.go#L30
In the timestamppb unit tests they disable the randomization, but the Disable
function comes from an internal package: https://github.com/protocolbuffers/protobuf-go/blob/fb0abd915897428ccfdd6b03b48ad8219751ee54/types/known/timestamppb/timestamp_test.go#L22
They also use a wrapper type to avoid direct equality comparisons which might be what we want to do here: https://github.com/protocolbuffers/protobuf-go/blob/fb0abd915897428ccfdd6b03b48ad8219751ee54/types/known/timestamppb/timestamp_test.go#L104
We could also not care about the exact error as long as some error is returned since it is the return value from a method of the timestamppb type we didn't implement ourselves.
All of this seems a bit silly, they are discouraging direct error comparisons but in a highly non-obvious way if I have to read the implementation to figure out what is happening.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The test also seems to pass reliably so this bit of magic in the proto package might not even be doing its job properly in that the error string isn't actually randomized, just unexpected. 🤷
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'll change the test check in the following PR (which is based on this and in the draft mode for now).
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
That works, thanks
Co-authored-by: Craig MacKenzie <[email protected]>
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM, would be nice to parse the returned errors in the tests with https://pkg.go.dev/google.golang.org/grpc/status#Convert but not blocking my approval on that.
/test |
/test |
/test |
In
StrictMode
required fields are:Closes #79