Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix file loader for JSON object files #11801

Merged
merged 2 commits into from
Aug 21, 2024
Merged

Fix file loader for JSON object files #11801

merged 2 commits into from
Aug 21, 2024

Conversation

delucis
Copy link
Member

@delucis delucis commented Aug 21, 2024

Changes

  • Sets filePath on collection entries in the file() loader when the loaded JSON is an object not array
  • There was an inconsistency in the two code paths that meant that objects had been overlooked
  • Amongst other things this fixes use of the image() schema utility which depends on filePath
  • There’s probably an argument for refactoring the loader to first normalize the data, then run the other logic to avoid inconsistencies in the future, but I took the quick fix path for now.

Testing

Used as a patch in some work in the astro.build repo and working as expected

Docs

n/a — bug fix only

Copy link

changeset-bot bot commented Aug 21, 2024

🦋 Changeset detected

Latest commit: e3e8314

The changes in this PR will be included in the next version bump.

Not sure what this means? Click here to learn what changesets are.

Click here if you're a maintainer who wants to add another changeset to this PR

@github-actions github-actions bot added the pkg: astro Related to the core `astro` package (scope) label Aug 21, 2024
delucis added a commit to withastro/astro.build that referenced this pull request Aug 21, 2024
This commit includes a temporary patch for Astro to fix a `file()` loader bug with the `image()` utility. This is fixed properly in withastro/astro#11801
@ematipico ematipico merged commit 9f943c1 into main Aug 21, 2024
13 checks passed
@ematipico ematipico deleted the chris/fix-file-loader branch August 21, 2024 11:17
@astrobot-houston astrobot-houston mentioned this pull request Aug 21, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
pkg: astro Related to the core `astro` package (scope)
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants