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

Validation of (adaptivecard.Attachment).Content is missing #208

Closed
atc0005 opened this issue Mar 21, 2023 · 0 comments · Fixed by #209
Closed

Validation of (adaptivecard.Attachment).Content is missing #208

atc0005 opened this issue Mar 21, 2023 · 0 comments · Fixed by #209
Assignees
Labels
bug Something isn't working card format/adaptivecard Adaptive Card support validation
Milestone

Comments

@atc0005
Copy link
Owner

atc0005 commented Mar 21, 2023

Overview

While working to implement support for #205 I spent some time reviewing the current codebase. I looked for places to work in the new support without breaking existing logic. During this work, I found issues with the current validation logic.

The validation logic is intended to flow from the adaptivecard.Message entry point to all associated types like so:

  • Message
    • Attachments ([]Attachments)
      • Attachment
        • Content (TopLevelCard)
          • Card
            • Body ([]Element)
              • Element
                • many branching paths

Unfortunately, validation breaks down here:

  • Message
    • Attachments ([]Attachments)
      • Attachment

func (a Attachment) Validate() error {
v := validator.Validator{}
v.FieldHasSpecificValue(
a.ContentType,
"attachment type",
AttachmentContentType,
"attachment",
ErrInvalidType,
)
return v.Err()
}

What should occur is a call to validate Attachment.Content. This in turn should validate all required fields and trigger validation of any associated types downwards or outwards so that everything that should be validated is validated.

@atc0005 atc0005 added the bug Something isn't working label Mar 21, 2023
@atc0005 atc0005 added this to the v2.7.1 milestone Mar 21, 2023
@atc0005 atc0005 self-assigned this Mar 21, 2023
atc0005 added a commit that referenced this issue Mar 21, 2023
Restore validation logic "chain" by adding missing validation
step. By adding this step, the validation logic can continue
"downwards" or "outwards" to associated types as intended.

NOTE: This change does not affect the ability to disable
validation entirely if requested by client code.

refs GH-208
@atc0005 atc0005 changed the title Validation of adaptivecard.Attachment is missing Validation of (adaptivecard.Attachment).Content is missing Mar 21, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working card format/adaptivecard Adaptive Card support validation
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant