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

[LintDiff] AggregateError is not showing constituent errors. Original bug report: error encountered: Error: Error running Nimma #6856

Closed
konrad-jamrozik opened this issue Aug 25, 2023 · 2 comments
Assignees
Labels
Central-EngSys This issue is owned by the Engineering System team. Spec PR Tools Tooling that runs in azure-rest-api-specs repo.

Comments

@konrad-jamrozik
Copy link
Contributor

konrad-jamrozik commented Aug 25, 2023

Update 9/20/2023

Known cases from Teams discussion:

Getting more info from the error

Investigation trail, chronologically:

Where the AggregateError.errors property is defined?

About Spectral and Nimma

Per this doc:

Spectral uses nimma as its main implementation, and sometimes resorts to jsonpath-plus to ensure backwards-compatibility.

@konrad-jamrozik konrad-jamrozik self-assigned this Aug 25, 2023
@konrad-jamrozik konrad-jamrozik added the Central-EngSys This issue is owned by the Engineering System team. label Aug 25, 2023
@konrad-jamrozik konrad-jamrozik added the Spec PR Tools Tooling that runs in azure-rest-api-specs repo. label Aug 25, 2023
@github-actions github-actions bot added the needs-triage Workflow: This is a new issue that needs to be triaged to the appropriate team. label Aug 25, 2023
@kurtzeborn kurtzeborn removed the needs-triage Workflow: This is a new issue that needs to be triaged to the appropriate team. label Aug 28, 2023
@kurtzeborn kurtzeborn moved this from 🤔 Triage to 📋 Backlog in Azure SDK EngSys 🚢🎉 Aug 28, 2023
@konrad-jamrozik konrad-jamrozik moved this to 📋 Backlog in Spec PR Tools Sep 20, 2023
@konrad-jamrozik konrad-jamrozik moved this from 📋 Backlog to 🐝 Dev in Azure SDK EngSys 🚢🎉 Sep 21, 2023
@konrad-jamrozik konrad-jamrozik changed the title [LintDiff] error encountered: Error: Error running Nimma [LintDiff] AggregateError is not showing constituent errors. Original bug report: error encountered: Error: Error running Nimma Sep 21, 2023
@konrad-jamrozik konrad-jamrozik changed the title [LintDiff] AggregateError is not showing constituent errors. Original bug report: error encountered: Error: Error running Nimma [LintDiff] AggregateError is not showing constituent errors. Original bug report: error encountered: Error: Error running Nimma Sep 21, 2023
@konrad-jamrozik
Copy link
Contributor Author

konrad-jamrozik commented Sep 21, 2023

Conclusion

OK, so the problem is as follows: the error error encountered: Error: Error running Nimma is in fact an es-aggregate-error thrown from Spectral (see above for details). LintDiff currently is not printing out the details of the errors aggregated in it. This PR I just opened fixes this:

Looks to me that Spectral is using nimma to query JSON elements (a'la JSONPath) and runs rules from our spectral ruleset on them. If they fail with exception, it results in such aggregate exception, hiding the details of the failures.

Bug in patchPropertiesCorrespondToPutProperties rule uncovered during my local repro

My local repro of the problem on the PR:

with a call like this one:

autorest --v3 --spectral --azure-validator --use=./packages/azure-openapi-validator/autorest --tag=package-preview-2023-08 <local clone of azure-openapi-validator>/specs/specification/app/resource-manager/readme.md

has revealed all occurrences of AggregateError: Error running Nimma originate from a problem with patchPropertiesCorrespondToPutProperties.

For example:

fatal   | spectralPluginFunc: Failed validating: '<local clone>/specification/app/resource-manager/Microsoft.App/preview/2023-08-01-preview/Usages.json'. Errors encountered:
AggregateError: Error running Nimma
Error 1: $[paths,'x-ms-paths'].* threw: ErrorWithCause("Function \"patchPropertiesCorrespondToPutProperties\" threw an exception: Cannot read properties of undefined (reading 'length')")
Error 2: $[paths,'x-ms-paths'].* threw: ErrorWithCause("Function \"patchPropertiesCorrespondToPutProperties\" threw an exception: Cannot read properties of undefined (reading 'length')")

Appears to me the bug is here:

That is, patchBodyProperties may be undefined, resulting in the reported exception of Cannot read properties of undefined (reading 'length').

Note on error occurrence

The error logs of form error encountered: Error: Error running Nimma go at least as far as 2023-04-03, increasing over time (query link):

// Logs confirmed present, selected days:
// before 2023-04-03: did not check
// 2023-04-03 - 64,
// 2023-04-06 - 120,
// 2023-05-02 - 150,
// 2023-06-08 - 182,
// 2023-06-15 - 64,
// 2023-06-21 - 240,
// 2023-07-03 - 144,
// 2023-07-06 - 144,
// 2023-07-11 - 680,
// 2023-08-01 - 5k,
// 2023-09-19 - 12.4k
// 2023-09-20 - 16.6k
SpecsPipelinesBuildsJobLogs("LintDiff", ago(2d), now())
| where Message has "Error running Nimma"
| summarize count() by bin(Timestamp, 1d)

FYI @rkmanda @TimLovellSmith @bdefoy

@konrad-jamrozik konrad-jamrozik moved this from 📋 Backlog to 🐝 In Progress in Spec PR Tools Sep 21, 2023
@github-project-automation github-project-automation bot moved this from 🐝 Dev to 🎊 Closed in Azure SDK EngSys 🚢🎉 Sep 22, 2023
@github-project-automation github-project-automation bot moved this from 🐝 In Progress to 🎊 Closed in Spec PR Tools Sep 22, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Central-EngSys This issue is owned by the Engineering System team. Spec PR Tools Tooling that runs in azure-rest-api-specs repo.
Projects
Archived in project
Status: 🎊 Closed
Development

No branches or pull requests

2 participants