Skip to content

Generate an empty JSON object for container registry configs - #2079

Open
Bin Du (northtyphoon) wants to merge 2 commits into
PowerShell:masterfrom
northtyphoon:fix/oci-empty-json-config
Open

Bin Du (northtyphoon) wants to merge 2 commits into
PowerShell:masterfrom
northtyphoon:fix/oci-empty-json-config

Conversation

@northtyphoon

@northtyphoon Bin Du (northtyphoon) commented Nov 4, 2026 •

Copy link
Copy Markdown

PR Summary

Generate the OCI config blob as {} instead of a zero-byte file when publishing to a container registry.

  • Upload the generated config file using its SHA-256 digest instead of uploading a separate empty blob.
  • Generate a unique config path up front so an existing module nupkg/config.json cannot cause hashing and upload to use different files.
  • Set the manifest config size to the UTF-8 byte count of {} (2 bytes), retaining application/vnd.oci.image.config.v1+json.
  • Add offline regression tests for config content and digest, manifest descriptors, uploaded bytes, upload failures, and publishing with an existing module config file.

Validation

  • .\build.ps1 -Build -BuildConfiguration Debug -BuildFramework net472 - passed.
  • Invoke-Pester .\test\PublishPSResourceTests\ContainerRegistryConfig.Tests.ps1 -Output Detailed -PassThru - passed, 5/5 tests on both PowerShell Core and Windows PowerShell 5.1, with the built module imported and Pester 5.7.1.
  • git --no-pager diff --check - passed.
  • Not run: live Azure Container Registry integration tests or the CI Pester 4.x runner.

PR Context

The config descriptor advertises a JSON media type, but the previous config blob was empty and therefore could not be parsed as JSON. Publishing an empty JSON object makes the content valid JSON while keeping the descriptor's digest and size consistent with the uploaded bytes. The package layer and existing media types are unchanged; no command syntax or documentation changes are required.

PR Checklist

Upload the config blob using its matching digest and advertise its two-byte size in the OCI manifest. Add focused config and upload regression tests.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>

Copilot-Session: 7d4b68cd-b7b7-476b-a441-4e443201413b
@azure-pipelines

Copy link
Copy Markdown
Azure Pipelines:
There may be pipelines that require an authorized user to comment /azp run to run.

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

🟡 Changes recommended

An existing nupkg/config.json can cause hashing and upload to use different files, producing a digest mismatch that makes the registry reject the publish.

1 open issue
What changed in this PR

This PR updates container registry publishing to use {} as the OCI config blob instead of an empty file, keeping the uploaded content and manifest descriptor consistent.

Changes:

  • Create and upload the JSON config using its SHA-256 digest.
  • Set the manifest config size to 2 bytes while preserving existing media types.
  • Add offline regression tests for config content, descriptors, uploads, and upload failures.
File Description
test/​PublishPSResourceTests/​ContainerRegistryConfig.Tests.ps1 Adds offline tests for config generation and uploading.
src/​code/​ContainerRegistryServerAPICalls.cs Generates and uploads {} and updates the manifest config size.

Review effort: Balanced

Choose the config filename before creating, hashing, and uploading it, and remove the helper's unreported path substitution. Cover publishing with an existing module config.json without overwriting its content.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>

Copilot-Session: 7d4b68cd-b7b7-476b-a441-4e443201413b

This branch has not been deployed

No deployments
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