From 66120b937e915baac5ab00183e398e07b7801de6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Manuel=20R=C3=BCger?= Date: Thu, 12 Mar 2026 23:05:55 +0100 Subject: [PATCH] fix: handle nil meta in dry-run mode when PageID is set page.ResolvePage requires non-nil metadata and would error immediately when called with meta == nil (e.g. when --page-id is used and the file has no metadata header, or when metadata is intentionally suppressed). Guard the call: when meta != nil use ResolvePage as before; when meta is nil but PageID is provided, validate the page exists via api.GetPageByID instead; when neither is set the earlier mandatory- field check already returns an error, so no further action is needed. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> --- mark.go | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/mark.go b/mark.go index e363ef2..637a3be 100644 --- a/mark.go +++ b/mark.go @@ -234,8 +234,14 @@ func ProcessFile(file string, api *confluence.API, config Config) (*confluence.P markdown = page.SubstituteLinks(markdown, links) if config.DryRun { - if _, _, err := page.ResolvePage(true, api, meta); err != nil { - return nil, fmt.Errorf("unable to resolve page location: %w", err) + if meta != nil { + if _, _, err := page.ResolvePage(true, api, meta); err != nil { + return nil, fmt.Errorf("unable to resolve page location: %w", err) + } + } else if config.PageID != "" { + if _, err := api.GetPageByID(config.PageID); err != nil { + return nil, fmt.Errorf("unable to resolve page by ID: %w", err) + } } }