Skip to content

Fix Missing Publishing Context HTTP Error#814

Merged
MrSkwiggs merged 3 commits intomainfrom
bugfix/publishing-context-http-error
May 12, 2025
Merged

Fix Missing Publishing Context HTTP Error#814
MrSkwiggs merged 3 commits intomainfrom
bugfix/publishing-context-http-error

Conversation

@MrSkwiggs
Copy link
Copy Markdown
Collaborator

We actually weren’t passing the relevant HTTP errors to ErrorPages (either we never did, or it broke at some point without anyone noticing). The existing tests only checked for static strings, so they didn’t catch that the actual error instances weren’t being passed around correctly.

That’s now fixed, and the tests have been updated to properly check for this going forward.

@MrSkwiggs MrSkwiggs requested a review from Copilot April 29, 2025 14:00
@MrSkwiggs MrSkwiggs self-assigned this Apr 29, 2025
Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull Request Overview

This PR fixes an issue where HTTP error details were not being passed to ErrorPages during publishing. Key changes include:

  • Enhancing TestErrorPage to accept an errorChecker closure for HTTP errors.
  • Updating the Site tests to verify the proper HTTP error is passed.
  • Refactoring PublishingContext-Rendering and EnvironmentValues to pass HTTPError explicitly.

Reviewed Changes

Copilot reviewed 4 out of 4 changed files in this pull request and generated 1 comment.

File Description
Tests/IgniteTesting/TestWebsitePackage/Sources/TestErrorPage.swift Adds an initializer and errorChecker closure to TestErrorPage to verify HTTPError propagation.
Tests/IgniteTesting/Publishing/Site.swift Updates tests to compare the expected error status with the one passed to TestErrorPage.
Sources/Ignite/Publishing/PublishingContext-Rendering.swift Removes direct environment assignment and passes HTTPError via the initializer.
Sources/Ignite/Framework/Environment/EnvironmentValues.swift Updates initializers to accept and store a HTTPError instance.
Comments suppressed due to low confidence (1)

Sources/Ignite/Publishing/PublishingContext-Rendering.swift:153

  • Verify that passing HTTPError via the initializer fully replaces the previous behavior of setting environment.httpError directly, ensuring that all downstream consumers receive the correct error instance.
httpError: error

@MrSkwiggs MrSkwiggs requested a review from JPToroDev April 29, 2025 14:05
Copy link
Copy Markdown
Collaborator

@JPToroDev JPToroDev left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Great catch! Couple small notes, otherwise looks great!

allContent: [Article],
pageMetadata: PageMetadata,
pageContent: any LayoutContent
pageContent: any LayoutContent,
Copy link
Copy Markdown
Collaborator

@JPToroDev JPToroDev Apr 29, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can we create a dedicated init that mirrors the other convenience initializers?

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not sure what you mean by this? EnvironmentValues has 5 different inits and I only modified the one that required the fix

let expectedError = PageNotFoundError()

let errorPage = TestErrorPage(title: "A different title", description: "A different description") { error in
#expect(error.statusCode == expectedError.statusCode)
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could we simply check #expect(errorPage.error.statusCode == expectedError.statusCode) instead of introducing the errorChecker closure?

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Heya sorry for the delay, life happened.

Unless I'm missing something, checking the page's error after calling site.publish() will not work as it's set (and reset) dynamically during publishing?

What I want the test to do is to guarantee that the correct error is present during site publishing. I can only do so by injecting this check when the rendering actually happens.

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Gotcha—thanks for clarifying!

@MrSkwiggs MrSkwiggs force-pushed the bugfix/publishing-context-http-error branch from d15ddaa to 2df9f80 Compare May 9, 2025 11:25
@MrSkwiggs MrSkwiggs changed the title 🐛 Fix Missing Publishing Context HTTP Error Fix Missing Publishing Context HTTP Error May 9, 2025
@MrSkwiggs MrSkwiggs requested review from JPToroDev and Copilot May 9, 2025 11:42
Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull Request Overview

This PR fixes the missing publishing context HTTP error by ensuring that HTTP errors are correctly passed to ErrorPages and updating tests accordingly.

  • Updated TestErrorPage to include an errorChecker closure that validates the HTTPError.
  • Modified the Site test to assert against the expected HTTPError.
  • Adjusted PublishingContext and EnvironmentValues initializers to propagate the HTTPError to downstream components.

Reviewed Changes

Copilot reviewed 4 out of 4 changed files in this pull request and generated 1 comment.

File Description
Tests/IgniteTesting/TestWebsitePackage/Sources/TestErrorPage.swift Added an errorChecker parameter and updated the body to invoke it.
Tests/IgniteTesting/Publishing/Site.swift Updated test to verify the HTTPError via errorChecker.
Sources/Ignite/Publishing/PublishingContext-Rendering.swift Removed direct assignment of environment.httpError and passed httpError to the PageMetadata initializer.
Sources/Ignite/Framework/Environment/EnvironmentValues.swift Added httpError parameter to the initializer and set it in EnvironmentValues.
Comments suppressed due to low confidence (1)

Sources/Ignite/Publishing/PublishingContext-Rendering.swift:152

  • [nitpick] Since the HTTP error is now passed explicitly via the initializer, please confirm that downstream components utilize the provided 'httpError' and do not depend on a global assignment.
pageContent: site.errorPage,

@MrSkwiggs MrSkwiggs merged commit 4ac74d1 into main May 12, 2025
1 check passed
@MrSkwiggs MrSkwiggs deleted the bugfix/publishing-context-http-error branch May 12, 2025 14:54
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.

3 participants