Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ValidateCompatibility fix #49

Merged
merged 2 commits into from
Aug 22, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 6 additions & 2 deletions atp/client.go
Original file line number Diff line number Diff line change
Expand Up @@ -164,23 +164,27 @@ func (c *client) executeWriteLoop(
return
} else {
// It's not supposed to be not ok yet.
c.logger.Errorf("error in channel preparing to send signal over ATP")
c.logger.Errorf("error in channel preparing to send signal (step %s, signal %s) over ATP",
stepData.ID, signal.ID)
return
}
}
if isDone {
c.logger.Errorf("signal received after step '%s' completed. Ignoring signal '%s'", stepData.ID, signal.ID)
return
}
c.logger.Debugf("Sending signal with ID '%s' to step with ID '%s'", signal.ID, stepData.ID)
if err := c.encoder.Encode(RuntimeMessage{
MessageTypeSignal,
signalMessage{
StepID: stepData.ID,
SignalID: signal.ID,
Data: signal.InputData,
}}); err != nil {
c.logger.Errorf("Step %s failed to write signal (%s) with message: %w", stepData.ID, signal.ID, err)
c.logger.Errorf("Step %s failed to write signal (%s) with error: %w", stepData.ID, signal.ID, err)
return
}
c.logger.Debugf("Successfully sent signal with ID '%s' to step with ID '%s'", signal.ID, stepData.ID)
}
}

Expand Down
4 changes: 3 additions & 1 deletion schema/oneof.go
Original file line number Diff line number Diff line change
Expand Up @@ -246,7 +246,9 @@ func (o OneOfSchema[KeyType]) validateMap(data map[string]any) error {
selectedTypeIDAsserted, o.getTypeValues()),
}
}
delete(data, o.DiscriminatorFieldNameValue) // The discriminator isn't part of the object.
if selectedSchema.Properties()[o.DiscriminatorFieldNameValue] == nil { // Check to see if the discriminator is part of the sub-object.
delete(data, o.DiscriminatorFieldNameValue) // The discriminator isn't part of the object.
}
err := selectedSchema.ValidateCompatibility(data)
if err != nil {
return &ConstraintError{
Expand Down
2 changes: 1 addition & 1 deletion schema/property.go
Original file line number Diff line number Diff line change
Expand Up @@ -150,7 +150,7 @@ func (p *PropertySchema) ValidateCompatibility(typeOrData any) error {
}
err := p.TypeValue.ValidateCompatibility(typeOrData)
if err != nil {
if p.DisplayValue != nil {
if p.DisplayValue != nil && p.Display().Name() != nil {
return &ConstraintError{
Message: fmt.Sprintf("error while validating sub-type of property %s with type %T (%s)",
*p.Display().Name(), p.TypeValue, err),
Expand Down