Skip to content

Handle unknown WordPress publish statuses by warning and defaulting to draft#267

Merged
ashishb merged 3 commits into
mainfrom
copilot/log-warning-on-unknown-status
Apr 19, 2026
Merged

Handle unknown WordPress publish statuses by warning and defaulting to draft#267
ashishb merged 3 commits into
mainfrom
copilot/log-warning-on-unknown-status

Conversation

Copilot AI commented Apr 19, 2026

Copy link
Copy Markdown
Contributor

Some WordPress exports contain unexpected wp:status values. The parser currently aborts on unknown statuses, which interrupts migration for otherwise valid content.

  • Parser behavior update

    • Replaced fatal handling for unknown publish status with a warning.
    • Unknown statuses now fall back to draft so conversion continues safely.
    • Existing trash handling is unchanged (still ignored as before).
  • Status typing cleanup

    • Normalized status handling to use the PublishStatus type throughout the switch/fallback path, avoiding string-type round trips.
  • Coverage added

    • Added targeted parser tests for:
      • unknown status → mapped to draft
      • trash status → ignored via existing error path
publishStatus := PublishStatus(item.Extensions["wp"]["status"][0].Value)
switch publishStatus {
case PublishStatusTrash:
	return nil, fmt.Errorf("%w, ignored: %s", errTrashItem, item.Title)
default:
	log.Warn().Msgf("Unknown publish status: '%s' for '%s'. Mapping to draft.", publishStatus, item.Title)
	publishStatus = PublishStatusDraft
}

@ashishb

ashishb commented Apr 19, 2026

Copy link
Copy Markdown
Owner

@copilot fix the lint error

Agent-Logs-Url: https://github.com/ashishb/wp2hugo/sessions/c192457e-6221-4711-83fb-a1f195ccd286

Co-authored-by: ashishb <389236+ashishb@users.noreply.github.com>

Copilot AI commented Apr 19, 2026

Copy link
Copy Markdown
Contributor Author

@copilot fix the lint error

Fixed in commit d031b49. I updated the test assertion to use require.ErrorIs(...) (as required by testifylint), replacing require.True(errors.Is(...)).

Copilot AI requested a review from ashishb April 19, 2026 08:17
@ashishb ashishb merged commit 6be78e6 into main Apr 19, 2026
3 checks passed
@ashishb ashishb deleted the copilot/log-warning-on-unknown-status branch April 19, 2026 08:35
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

Successfully merging this pull request may close these issues.

2 participants