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

Running diff for resolved issues and html output results in error #3909

Open
geeksmith opened this issue May 15, 2023 · 2 comments
Open

Running diff for resolved issues and html output results in error #3909

geeksmith opened this issue May 15, 2023 · 2 comments

Comments

@geeksmith
Copy link
Contributor

Describe the bug
When running 'CodeChecker cmd diff --resolved --output html ...' I get this stack trace:

   49m24s CodeChecker    [INFO 2023-05-15 11:01] - Matching local report directories (--newname): /<path>/ccreports
   49m24s CodeChecker    [INFO 2023-05-15 11:01] - Given remote runs (--baseline): baseline_devel
   49m24s CodeChecker    [INFO 2023-05-15 11:01] - Checking local passwords or tokens in /<path>/ccreports/codechecker.passwords.json
   49m24s CodeChecker    [INFO 2023-05-15 11:01] - Checking for local valid sessions.
   54m21s CodeChecker    Traceback (most recent call last):
   54m21s CodeChecker      File "/usr/local/lib/python3.9/dist-packages/codechecker_common/cli.py", line 209, in main
   54m21s CodeChecker        sys.exit(args.func(args))
   54m21s CodeChecker      File "/usr/local/lib/python3.9/dist-packages/codechecker_client/cmd/cmd.py", line 584, in __handle
   54m21s CodeChecker        cmd_line_client.handle_diff_results(args)
   54m21s CodeChecker      File "/usr/local/lib/python3.9/dist-packages/codechecker_client/cmd_line_client.py", line 1292, in handle_diff_results
   54m21s CodeChecker        get_diff_remote_run_local_dir(
   54m21s CodeChecker      File "/usr/local/lib/python3.9/dist-packages/codechecker_client/cmd_line_client.py", line 1024, in get_diff_remote_run_local_dir
   54m21s CodeChecker        filtered_reports.extend(convert_report_data_to_report(results))
   54m21s CodeChecker      File "/usr/local/lib/python3.9/dist-packages/codechecker_client/cmd_line_client.py", line 858, in convert_report_data_to_report
   54m21s CodeChecker        report = report_type_converter.to_report(
   54m21s CodeChecker      File "/usr/local/lib/python3.9/dist-packages/codechecker_client/report_type_converter.py", line 68, in to_report
   54m21s CodeChecker        get_file(report.fileId, report.checkedFile),
   54m21s CodeChecker      File "/usr/local/lib/python3.9/dist-packages/codechecker_client/cmd_line_client.py", line 813, in cached_report_file_lookup
   54m21s CodeChecker        file_cache[file_id].content = convert.from_b64(
   54m21s CodeChecker      File "/usr/local/lib/python3.9/dist-packages/codechecker_web/shared/convert.py", line 22, in from_b64
   54m21s CodeChecker        return base64.b64decode(string_b64.encode("utf-8")).decode(
   54m21s CodeChecker    AttributeError: 'NoneType' object has no attribute 'encode'

CodeChecker version
6.21.0-rc (installed via pip)

To Reproduce

  1. Run analysis on project and store results on server.
  2. Cherry-pick new commit containing changes, possible fixes, possible new defects.
  3. Run diff command to check for new issues: CodeChecker cmd diff --new --uniqueing on --url https://<url> --basename baseline_devel --newname /<path>/ccreports --output html --export-dir /<path>/ccreports/ccdiff-resolved
  4. Run diff command to check for resolved issues: CodeChecker cmd diff --resolved --uniqueing on --url https://<url> --basename baseline_devel --newname /<path>/ccreports --output html --export-dir /<path>/ccreports/ccdiff-resolved1
  5. Received error above.

Expected behaviour
I expect a report of issues that were resolved in the cherry-picked change.

Desktop (please complete the following information)

  • OS: Ubuntu Jammy 20.04
  • Browser: N/A
  • Version: N/A

Additional context
Seems like there's some entry either locally or in the remote database that has an empty value that CodeChecker isn't expecting.

@geeksmith
Copy link
Contributor Author

This gets past the error but I'm not sure what side effects it may introduce:

diff --git a/web/client/codechecker_client/cmd_line_client.py b/web/client/codechecker_client/cmd_line_client.py
index f73b3af2..7a51ea1b 100644
--- a/web/client/codechecker_client/cmd_line_client.py
+++ b/web/client/codechecker_client/cmd_line_client.py
@@ -787,7 +787,7 @@ def handle_diff_results(args):
                 source = client.getSourceFileData(
                     file_id, True, ttypes.Encoding.BASE64)
                 file_cache[file_id].content = convert.from_b64(
-                    source.fileContent)
+                    source.fileContent) if hasattr(source.fileContent, "encode") else source.fileContent
 
         return file_cache[file_id]

@geeksmith
Copy link
Contributor Author

Passing '--uniqueing off' avoids this error without any changes to source code.

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

No branches or pull requests

1 participant