Skip to content
This repository has been archived by the owner on May 15, 2024. It is now read-only.

Define the referrers API responses for two edge cases #58

Merged
merged 1 commit into from
Oct 15, 2021

Conversation

lahirurd
Copy link
Contributor

This defines the response for the following cases:

  1. When the given subject has no referencing artifacts.
  2. When the given subject does not exist in the repository.

Returning an error code for the second scenario makes the api's response after the subject is deleted, consistent between registries that do signature clean up and those that do not. It also makes the response deterministic in registries that clean up signatures asynchronously.

Resolves #37

@lahirurd lahirurd requested a review from a team as a code owner September 23, 2021 17:46
Copy link
Contributor

@SteveLasker SteveLasker left a comment

Choose a reason for hiding this comment

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

Thanks @lahirurd,
This is great to help with consistency and clarity.
A few clarity suggests and a question on the wording.

manifest-referrers-api.md Outdated Show resolved Hide resolved
@@ -151,6 +151,10 @@ GET /oras/artifacts/v1/{repository}/manifests/{digest}/referrers?n=10&artifactTy
GET /oras/artifacts/v1/net-monitor/manifests/sha256:3c3a4604a545cdc127456d94e421cd355bca5b528f4a9c1905b15da2eb4a4c6b/referrers?n=10&artifactType=application%2Fvnd.org.cncf.notary.v2
```

### Error Handling

If the `subject` identified by the digest does not exist in the repository, the registry MUST return a `404` response with the error code `MANIFEST_UNKNOWN`.
Copy link
Contributor

Choose a reason for hiding this comment

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

I believe you mean subject here is what's passed as the manifest/. However, using subject in this context is a bit confusing as it's technically the subject of the referred artifacts, but we don't use 'subjectas the parameter name in the referrers examples. We can also remove some of the wording around the repository, as the/referrers` API is already scoped to a repository.

If the digest does not exist, the registry MUST return a 404 response with the error code MANIFEST_UNKNOWN.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

The reason I used subject there was for consistency, because we currently define the response with

- `references`: A list of [artifact descriptors][descriptor] that reference the given `subject`.

Should I change both?

If we were to word this as "If the <something> does not exist...", I'd rather <something> be "manifest" instead of "digest", since the API is scoped to a manifest. So I'd be happy with "If the manifest does not exist...".

I added "in the repository" there to remove possible ambiguity that could come up in future cross repo reference scenarios (e.g. issue #26). However if we consider the repository+manifest params in the call strictly scoping to a manifest (which is what we're currently doing), I agree this it isn't required.

Copy link
Contributor

@SteveLasker SteveLasker Sep 27, 2021

Choose a reason for hiding this comment

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

Good catch:
I like your suggestion, and also like Sajay's point of clarity to suggest MANIFEST_SUBJECT_UNKNOWN as a bit more clarity. I do think we should add the scope of repository, as it's not really accurate to say the manifest is unknown in the registry, as it may very well be in another repository for the dev image that hasn't yet been promoted to the prod repository.
What about this tweaking:

If the manifest does not exist in the repository, the response MUST return a 404 response with the error code MANIFEST_SUBJECT_UNKNOWN

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I can add back the repository-scoping, but I believe MANIFEST_UNKNOWN is the right response for the referrers api. Sajay also agrees here. So it would be

If the manifest does not exist in the repository, the registry MUST return a 404 response with the error code MANIFEST_UNKNOWN.

manifest-referrers-api.md Outdated Show resolved Hide resolved
manifest-referrers-api.md Outdated Show resolved Hide resolved
sajayantony
sajayantony previously approved these changes Sep 24, 2021
@sajayantony
Copy link
Contributor

@SteveLasker @michaelb990 any concern merging this in?

@SteveLasker
Copy link
Contributor

Agreed to return an empty list if the digest is valid, and no artifacts exist that reference that digest.
A separate PR will track the question of inconsistencies in lifecycle management relating to validation the subject exists on push, yet the subject MAY get deleted, leaving the zombied artifacts.

sajayantony
sajayantony previously approved these changes Oct 13, 2021
1. When the given subject has no referencing artifacts.
2. When the given subject does not exist in the repository.

Signed-off-by: Lahiru Dissanayake <[email protected]>
@sajayantony
Copy link
Contributor

LGTM.

I'm ok merging this since the referrers API is now expected to handle the non-existing manifest case for the current draft.

This also is kind of off since the URI path is like a resource and you are able to get a non-404 from path under a resource(manifest) that might not exist. The supporting factor is that we are most likely to move to the extension model and move the digest to a parameter to support this kind of behavior in draft2 or vnext most likely.

We also might need to update oras-project/distribution once this gets merged.

/cc @avtakkar

Copy link
Contributor

@SteveLasker SteveLasker left a comment

Choose a reason for hiding this comment

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

LGTM

@SteveLasker SteveLasker merged commit 26ca107 into oras-project:main Oct 15, 2021
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

/referrers API error codes & behavior
3 participants