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

Update type specifiers in validation logging #16173

Merged
merged 1 commit into from
Jun 19, 2019

Conversation

talldan
Copy link
Contributor

@talldan talldan commented Jun 14, 2019

Description

Noticed while debugging a validation issue with a full-content test I'm working on. The warning logged had some incorrect formatting.

I was receiving the following error, which I initially found confusing:

"Expected attributes 0, instead saw 0."

I tracked this down to the line of code:

log.warning( 'Expected attributes %o, instead saw %o.', expected, actual );

According to the sprintf-js docs, %o is for an octal, so that explains the zeros. This PR changes the instances of %o to %j, which the library says will output a json representation of the parameter.

Tested and I received a better error, still not perfect, but an improvement:

["Expected attributes [], instead saw [[\"scope\",\"col\",true]]."]

I imagine this came about because of an update to the library or change of library used for those messages.

How has this been tested?

Detailed above. I reproduced by creating a validation error in one of the full-content tests (adding an attribute that wasn't produced in the save content), and then regenerating the fixtures. Jest will output the error in the terminal.

Screenshots

Types of changes

Bug fix (non-breaking change which fixes an issue)

Checklist:

  • My code is tested.
  • My code follows the WordPress code style.
  • My code follows the accessibility standards.
  • My code has proper inline documentation.
  • I've included developer documentation if appropriate.

@talldan talldan added [Type] Bug An existing feature does not function as intended [Package] Blocks /packages/blocks labels Jun 14, 2019
@talldan talldan self-assigned this Jun 14, 2019
Copy link
Member

@gziolo gziolo left a comment

Choose a reason for hiding this comment

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

Good catch. I double checked sprintf-js docs and your proposal makes the most sense 👍

I trust you and haven't tested it myself :)

@talldan talldan merged commit 651110b into master Jun 19, 2019
@talldan talldan deleted the fix/validation-log-message branch June 19, 2019 14:21
@youknowriad youknowriad added this to the Gutenberg 6.0 milestone Jun 24, 2019
@aduth
Copy link
Member

aduth commented Jun 25, 2019

I must have thought %o was for "object" 🤦‍♂Thanks for fixing.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
[Package] Blocks /packages/blocks [Type] Bug An existing feature does not function as intended
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants