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

metadatapath analyzer is being skipped #101

Closed
eh-am opened this issue Mar 13, 2023 · 4 comments · Fixed by #108
Closed

metadatapath analyzer is being skipped #101

eh-am opened this issue Mar 13, 2023 · 4 comments · Fixed by #108

Comments

@eh-am
Copy link
Contributor

eh-am commented Mar 13, 2023

Hi, the reviewer caught this error when I submitted to grafana, but I expected it to be caught way earlier in my ci lint step:

[must fix] The logo in the datasource list is broken. The path in plugin.json point to a non-existing file. Please include a logo in the zip file and/or adjust plugin.json accordingly:

Which seems to be analyzed by metadatapath:

pass.ReportResult(pass.AnalyzerName, pathNotExists, fmt.Sprintf("plugin.json: %s path doesn't exists: %s", path.kind, path.path), "Refer only existing files. Make sure the files referred in plugin.json are included in the archive.")

Debugging a little bit, I found that it was simply not being run!

For illustration, use the following config.yaml file:

global:
  enabled: false
  jsonOutput: false
  reportAll: true

analyzers:
  metadatapaths:
    enabled: true

I also found that removing the following loop "fixes" the issue:

for _, dep := range a.Requires {
if pass.ResultOf[dep] == nil {
return nil
}
}

I didn't look too much so I don't know how that affects other places.

@eh-am
Copy link
Contributor Author

eh-am commented Mar 15, 2023

Just to give some more information, it happens because I don't have any screenshots, so it returns nil here

Which then forces metadatapath to be skipped here

if pass.ResultOf[dep] == nil {

@academo
Copy link
Member

academo commented Mar 17, 2023

Hi @eh-am thanks for the bug report. Do you have a plugin archive file I can use to test this?

It seems the loop you mention seems to be indeed the problem but just removing it might bring problems for other validators so I want to check first the case and see if we can fix it somehow else.

@eh-am
Copy link
Contributor Author

eh-am commented Mar 17, 2023

Hi @academo, here's an example.

grafana-datasource-plugin-1.2.0.zip

I disabled all analyzers except metadatapaths.Analyzer in analysis/passes/analysis.go to make it easier to debug.

As I mentioned in the previous message (#101 (comment)) the problem seems to come from the screenshot analyzer, which returns null, making the metadatapath analyzer to return early.

This is plugincheck2 btw.

@academo
Copy link
Member

academo commented Mar 17, 2023

Thanks @eh-am I'll take a look. You should also feel free to open a PR if you want to fix this issue. Be mindful that removing the loop might not be the best option. My idea so far is to return an empty array in the screenshots analyzer.

Generally speaking I don't like our current use of interface{} in the analzyers return types and we might need to restructure all of it to use generics or retrospection. That's a refactor I haven't found the time to work on yet.

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 a pull request may close this issue.

2 participants