Skip to content

violation message string contains interpolated value, but is verbatim in JSON report #3384

@danielweck

Description

@danielweck

Product: axe-core

Expectation: violation message string interpolation should work

Actual: message appears verbatim, variable not substituted

Motivation: user text is not useful


axe-core version: 4.4.1

Any OS, any web browser

Source reference:

"fail": "The role used is deprecated: ${data.values}"

Verbatim message: The role used is deprecated: ${data.values}:

    {
        "id": "aria-roles",
        "impact": "minor",
        "tags": [
            "cat.aria",
            "wcag2a",
            "wcag412"
        ],
        "description": "Ensures all elements with a role attribute use a valid value",
        "help": "ARIA roles used must conform to valid values",
        "helpUrl": "https://dequeuniversity.com/rules/axe/4.4/aria-roles?application=axeAPI",
        "nodes": [
            {
                "any": [],
                "all": [],
                "none": [
                    {
                        "id": "deprecatedrole",
                        "data": "doc-endnote",
                        "relatedNodes": [],
                        "impact": "minor",
                        "message": "The role used is deprecated: ${data.values}"
                    }
                ],
                "impact": "minor",
                "html": "<p xmlns=\"http://www.w3.org/1999/xhtml\" role=\"doc-endnote\" xmlns:epub=\"http://www.idpf.org/2007/ops\" epub:type=\"rearnote\">bla bla</p>",
                "target": [
                    "p"
                ],
                "failureSummary": "Fix all of the following:\n  The role used is deprecated: ${data.values}"
            }
        ]
    }

To reproduce, create index.html and open in web browser + inspect debugger console to see Axe's JSON output:

<?xml version="1.0" encoding="utf-8"?>
<!DOCTYPE HTML>
<html xmlns="http://www.w3.org/1999/xhtml" xmlns:epub="http://www.idpf.org/2007/ops" lang="en" xml:lang="en">
<head>

<title>TITLE</title>

<script src="https://unpkg.com/axe-core@4.4.1/axe.min.js"></script>

</head>
<body>

<section role="doc-chapter">
<p role="doc-endnote" epub:type="rearnote">bla bla</p>
</section>

<script type="javascript">
    window.axe
    .run()
    .then(results => {
        console.log(JSON.stringify(results.violations, null, 4));
        console.log(results.violations.length);
    })
    .catch(err => {
      console.error('Something bad happened:', err.message);
    });
</script>
</body>
</html>

Metadata

Metadata

Assignees

No one assigned

    Labels

    fixBug fixesprA pr has been created for the issuerule metadataIssues in the rule metadata code (lib/rules)

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions