Open Bug 1771483 Opened 2 years ago Updated 5 months ago

`mach clang-format` prints misleading error messages due to requiring an exact version match when its config is out-of-date relative to our clang version

Categories

(Developer Infrastructure :: Lint and Formatting, defect, P3)

Tracking

(firefox-esr91 unaffected, firefox101 unaffected, firefox102 fixed)

REOPENED
102 Branch
Tracking Status
firefox-esr91 --- unaffected
firefox101 --- unaffected
firefox102 --- fixed

People

(Reporter: tjc, Unassigned)

References

(Regression)

Details

(Keywords: regression)

Attachments

(3 files)

User Agent: Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/101.0.4951.54 Safari/537.36

Steps to reproduce:

mach clang-format -s --outgoing

Actual results:

Output:

0:02.95 Setting up artifact clang-tidy.tar.zst
 0:02.95 Using artifact from local cache: /home/tjc/.mozbuild/toolchains/28739e61a849e888-clang-tidy.tar.zst
 0:03.10 untarring "/home/tjc/.mozbuild/clang-tools/clang-tidy.tar.zst"
 0:03.91 ERROR: You're using an old or incorrect version (clang-format version 14.0.4 (taskcluster-P6yBRSPoSOCJ3-sgYnaiUA)) of clang-format binary. Please update to a more recent one (at least > 14.0.3) by running: './mach bootstrap' 

When I checked the version of my clang-format binary, I got:

$ ~/.mozbuild/clang-tools/clang-tidy/bin/clang-format --version
clang-format version 14.0.4 (taskcluster-P6yBRSPoSOCJ3-sgYnaiUA)

Expected results:

Since 14.04 > 14.0.3, I would expect the command to succeed, or at least use "== 14.0.3" rather than "> 14.0.4" in the error message.

It seems that the bug is the _is_version_eligible() function in code_analysis/mach_commands.py ( https://searchfox.org/mozilla-central/source/python/mozbuild/mozbuild/code_analysis/mach_commands.py#515 ):

if version in current_version:
        return True

Since the string '14.0.4' doesn't exactly match '14.0.3', the command fails even though the clang-format version I have installed is newer than the required one.

Assignee: nobody → tjc
Status: NEW → ASSIGNED

I have a fix in D147523 -- requested review from firefox-build-system-reviewers. Hopefully that's the right procedure!

Regressed by: 1771242

--> clarifying summary to more precisely define the issue, in a way that makes sense in light of the fix (version-bump) that we landed.

(The original summary "mach clang-format requires exact version match" is describing a situation that still exists, though of course it's only troublesome when we have a version mismatch -- which we did, but no longer do, as of glandium's patch.)

Summary: `mach clang-format` requires exact version match → `mach clang-format` fails, due to requiring an exact version match and being out-of-date vs. our clang version
Status: ASSIGNED → RESOLVED
Closed: 2 years ago
Resolution: --- → FIXED
Target Milestone: --- → 102 Branch

I don't think this is fixed. What happens the next time someone forgets to bump the version? I spent half an hour trying to figure out why mach was telling me that 3 is greater than 4, and I would like it if the next person didn't have to. At the very least, can the error message be changed to use the '==' sign rather than '>'?

Status: RESOLVED → REOPENED
Resolution: FIXED → ---
  • Remove misleading error message that suggested mach will accept a newer
    version of clang-format than the expected one
  • Print the full path to config.yaml in some error messages to make it
    easier to diagnose errors
  • Log errors in code_analysis.utils methods rather than calling a non-
    existent logging method
  • Handle errors properly in code_analysis.utils() methods rather than
    crashing when _clang_tidy_config is None.
Summary: `mach clang-format` fails, due to requiring an exact version match and being out-of-date vs. our clang version → `mach clang-format` prints misleading error messages due to requiring an exact version match when its config is out-of-date relative to our clang version

I submitted a different fix in D147649 that only improves error messages and doesn't change version parsing.

Has Regression Range: --- → yes

Set release status flags based on info from the regressing bug 1771242

The severity field is not set for this bug.
:ahal, could you have a look please?

For more information, please visit auto_nag documentation.

Flags: needinfo?(ahal)
Severity: -- → S3
Flags: needinfo?(ahal)
Priority: -- → P3
Product: Firefox Build System → Developer Infrastructure

The bug assignee is inactive on Bugzilla, so the assignee is being reset.

Assignee: tjc → nobody
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Creator:
Created:
Updated:
Size: