Skip to content

Conversation

@sirugh
Copy link
Collaborator

@sirugh sirugh commented Aug 7, 2025

Closes #194

The reason this is happening is due to incorrect format in description data.

Technically this might happen for any user defined string which can be HTML.

This PR validates html for fields we are trying to template in that might be invalid.

DEBATE:

  • What do we do if the field is invalid? (log)
  • Do we check all "variables" being injected? (just shortDescription, description for now)

sirugh added 2 commits August 7, 2025 14:29
Signed-off-by: Stephen Rugh <rugh@adobe.com>
Signed-off-by: Stephen Rugh <rugh@adobe.com>

Object.entries(fieldValidations).forEach(([field, validation]) => {
if (!validation.valid) {
context.logger.warn(`Validation failed for "${field}" field: ${validation.reason}`);
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is this log sufficient to inform the user? Hopefully users do not have to experience what I did - tracing backwards from malformed UX through EDS CDN, Azure, and finally realizing it is the data itself that is the problem.

@duynguyen let me know if there's a better way to alert users to bad data.

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

the log message is good but it will potentially get lost among other logs.
IMO this should be tackled in a generic way, created #197

Copy link
Collaborator

@duynguyen duynguyen left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

changes looking good, can we have tests for the validation cases?

@sirugh
Copy link
Collaborator Author

sirugh commented Aug 11, 2025

@duynguyen I will write tests and let you know once I've pushed.

@buuhuu
Copy link
Collaborator

buuhuu commented Aug 11, 2025

Why don't we use a library to sanitize the html instead, allowing only the tags that edge delivery supports, or none if the meta descriptions becomes the content attribute of a <meta> tag?

https://www.npmjs.com/package/sanitize-html

sirugh added 2 commits August 11, 2025 14:09
Signed-off-by: Stephen Rugh <rugh@adobe.com>
…ests

Signed-off-by: Stephen Rugh <rugh@adobe.com>
@sirugh sirugh changed the title fix: validate html descriptions, set to empty string if invalid chore: validate html descriptions, warn if invalid Aug 11, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

incorrect structure generated for some products

3 participants