Skip to content

[bug] Fix misleading log message when os.WriteFile fails in export path (#9)#10

Merged
p0dalirius merged 1 commit into
mainfrom
bugfix-writefile-error-message
May 21, 2026
Merged

[bug] Fix misleading log message when os.WriteFile fails in export path (#9)#10
p0dalirius merged 1 commit into
mainfrom
bugfix-writefile-error-message

Conversation

@p0dalirius

Copy link
Copy Markdown
Contributor

Linked Issue

Closes #9

Root Cause

Two adjacent error branches in main.go (the JSON-serialization step and the file-write step) emitted the same log message: "Error exporting graph to file: %s". The wording was carried over by copy-paste; it correctly described the surrounding context but not the specific failure. Users seeing the message could not tell whether the in-memory marshaling (og.ExportJSON) or the filesystem write (os.WriteFile) had failed, which made diagnosis of permission/path/disk issues unnecessarily difficult.

Fix Description

Differentiate the two messages:

  • og.ExportJSON failure now logs "Error serializing graph to JSON: %s".
  • os.WriteFile failure now logs "Error writing graph to file <outputFile>: %s", including the destination path so the user immediately knows what file the write was targeting.

No other code paths reference the messages.

How Verified

Static: the two error branches in main.go are the only places that emitted the original string; both have been replaced with distinct, more specific messages, and the surrounding control flow is unchanged.
Runtime: go build succeeds. Help output and normal connection path are unchanged.

Test Coverage

None: the change is a log-string substitution with no behavioral effect; no test infrastructure exists in the repository.

Scope of Change

  • Files changed: main.go
  • Submodule pointer updated: no
  • Behavioral changes outside the bug fix: none

Distinguish the JSON serialization error from the file write error so
users can tell which stage failed: the first branch now logs "Error
serializing graph to JSON" and the second logs "Error writing graph to
file <path>", instead of both reporting "Error exporting graph to file".
@p0dalirius p0dalirius self-assigned this May 21, 2026
@github-actions github-actions Bot changed the title Fix misleading log message when os.WriteFile fails in export path (#9) [bug] Fix misleading log message when os.WriteFile fails in export path (#9) May 21, 2026
@github-actions github-actions Bot added the bug Something isn't working label May 21, 2026
@p0dalirius p0dalirius merged commit 199de0b into main May 21, 2026
8 checks passed
@p0dalirius p0dalirius deleted the bugfix-writefile-error-message branch May 21, 2026 08:47
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug Something isn't working

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Misleading log message when os.WriteFile fails in export path

1 participant