Skip to content

Do not crash diff when a source file is missing on the server - #5219

Open
mhammadtariq11 wants to merge 1 commit into
Ericsson:masterfrom
mhammadtariq11:fix/diff-missing-source-content
Open

mhammadtariq11 wants to merge 1 commit into
Ericsson:masterfrom
mhammadtariq11:fix/diff-missing-source-content

Conversation

@mhammadtariq11

Copy link
Copy Markdown
Contributor

CodeChecker cmd diff --resolved --output html crashed with
'NoneType' object has no attribute 'encode' when the source file of a
report was not available on the server anymore.

Why getSourceFileData() returns no content: the server returns an
empty SourceFileData if the file id is not in the database. Files can be
removed by the database garbage collection (run at server start), which
deletes every file that is not referenced by any bug path data
(report_path_data_files). The report's own file is not added there
explicitly, so the file of a report whose bug path is entirely in other
files can be removed while the report still refers to it.

Changes in the client:

  • Reports whose source file is not available on the server are skipped
    with a warning, since they cannot be converted (no file path, no source).
  • If the content of a file is not available (e.g. it was removed after the
    reports were queried), a warning is logged and the local version of the
    file is used. The HTML output already handles files that cannot be read.

Fixes #3909

Testing:

  • Reproduced the crash with a server where the file of a report was
    missing, using the command from the issue
    (cmd diff --resolved --uniqueing on --output html). With the fix the
    command finishes, logs a warning and the other reports are written to
    the HTML and table outputs.
  • Added unit tests for convert_report_data_to_report(): content from the
    server is used, missing content falls back to the local file, and a
    report without a source file on the server is skipped. Two of them fail
    with the error from the issue without this change.

"CodeChecker cmd diff --resolved --output html" crashed with
"'NoneType' object has no attribute 'encode'" when the source file of
a report was not available on the server anymore.

getSourceFileData() returns no content if the file is not in the
database, e.g. it was removed by the garbage collection. The
garbage collection removes files that are not referenced by any bug
path data, so the file of a report whose bug path is entirely in
other files can be removed.

- Reports whose source file is not available on the server are skipped
  with a warning, since they cannot be converted.
- If the content of a file is not available, a warning is logged and
  the local version of the file is used.

Fixes Ericsson#3909
@dkrupp dkrupp added bug 🐛 CLI 💻 Related to the command-line interface, such as the cmd, store, etc. commands bugfix 🔨 labels Nov 26, 2026
@dkrupp dkrupp modified the milestones: release 6.29.4, release 6.30.0 Nov 26, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug 🐛 bugfix 🔨 CLI 💻 Related to the command-line interface, such as the cmd, store, etc. commands

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Running diff for resolved issues and html output results in error

3 participants