Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
fix: prevent crash on null changelog markdown
  • Loading branch information
hearsilent committed Mar 18, 2026
commit c8535beb71bfe998140f44fd860b20c7aa3fb35a
24 changes: 24 additions & 0 deletions src/components/changelog-dialog.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -127,6 +127,30 @@ describe("ChangelogDialog", () => {
)
})

it("handles null body without crashing", () => {
changelogState.releases = [
{
id: 1,
tag_name: "v1.0.0",
name: "v1.0.0",
body: null as any,
published_at: "2024-01-02T00:00:00Z",
html_url: "https://github.com/robinebers/openusage/releases/tag/v1.0.0",
},
]

render(
<ChangelogDialog
currentVersion="1.0.0"
onBack={() => {}}
onClose={() => {}}
/>,
)

// If it renders the title, we know it didn't crash when rendering the markdown.
expect(screen.getByText("v1.0.0")).toBeInTheDocument()
})

it("shows link to full changelog when multiple releases exist", async () => {
changelogState.releases = [
{
Expand Down
4 changes: 2 additions & 2 deletions src/components/changelog-dialog.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { useEffect } from "react"
import { Loader2, X, ChevronRight, ExternalLink as ExternalLinkIcon } from "lucide-react"
import { Loader2, ChevronRight, ExternalLink as ExternalLinkIcon } from "lucide-react"
import { useChangelog } from "@/hooks/use-changelog"
import { Button } from "@/components/ui/button"
import { openUrl } from "@tauri-apps/plugin-opener"
Expand Down Expand Up @@ -238,7 +238,7 @@ export function ChangelogDialog({ currentVersion, onBack, onClose }: ChangelogDi
</div>

<div className="bg-muted/10 rounded-lg p-1">
<SimpleMarkdown content={currentRelease.body} />
<SimpleMarkdown content={currentRelease.body ?? ""} />
</div>

{releases.length > 1 && (
Expand Down