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

Should we gracefully handle cases where servers do not support (even) shape tree auxiliary metadata? #46

Open
justinwb opened this issue Aug 9, 2021 · 2 comments
Labels
question Further information is requested

Comments

@justinwb
Copy link
Member

justinwb commented Aug 9, 2021

Currently we throw an exception when the client cannot discover a shapetree metadata auxiliary resource advertised by the solid server. Should clients gracefully handle these cases? Options would be:

  1. Don't do any validation at all - act like a normal client
  2. Use an alternative location, such as a general metadata auxiliary resource... Given the fact that our logic relies on the server providing link relations to locators, I'm not sure this would be feasible. If the server could be configured to do that, it could be configured to just do it properly in the first place.
  3. Halt and catch fire
@NotNull
public String getMetadataURI() throws IOException {
    if (!this.parsedLinkHeaders.containsKey(LinkRelations.SHAPETREE_LOCATOR.getValue())) {
        log.error("The resource {} does not contain a link header of {}", this.getUri(), LinkRelations.SHAPETREE_LOCATOR.getValue());
        // TODO: Should this be gracefully handled by the client?
        throw new ShapeTreeException(500, "No Link header with relation of " + LinkRelations.SHAPETREE_LOCATOR.getValue() + " found");
    }
    String metaDataURIString = this.parsedLinkHeaders.get(LinkRelations.SHAPETREE_LOCATOR.getValue()).stream().findFirst().orElse(null);
    if (metaDataURIString != null && metaDataURIString.startsWith("/")) {
        // If the header value doesn't include scheme/host, prefix it with the scheme & host from container
        URI shapeTreeContainerURI = this.getUri();
        String portFragment;
        if (shapeTreeContainerURI.getPort() > 0) {
            portFragment = ":" + shapeTreeContainerURI.getPort();
        } else {
            portFragment = "";
        }
        metaDataURIString = shapeTreeContainerURI.getScheme() + "://" + shapeTreeContainerURI.getHost() + portFragment + metaDataURIString;
    }

    if (metaDataURIString == null) {
        throw new ShapeTreeException(500, "No Link header with relation of " + LinkRelations.SHAPETREE_LOCATOR.getValue() + " found");
    }

    return metaDataURIString;
}
@justinwb justinwb added the question Further information is requested label Aug 9, 2021
@ericprud
Copy link
Collaborator

I think the use case for this is if some program uses the code for interception and it has to talk to multiple PODs, some which preserve aux data. For those that don't, the client program could impose its own user-configurable conventions via an extended -client-http API. The program needs to:

  1. catch our current exceptions to know that some site isn't accepting or regurgitating aux data headers,
  2. override HttpRemoteResource.getMetadataURI() (or, more obliquely, imitate the server functionality by extending HtttpClient.fetchIntoRemoteResource()

This might all be doable by extending an existing HttpClient.

@justinwb
Copy link
Member Author

  1. catch our current exceptions to know that some site isn't accepting or regurgitating aux data headers

This is probably the right place to start (and maybe where to stay). I guess it boils down to more graceful handling with a bit more informative logging. I think keeping a bit of (in-memory) cache about servers that don't support shape trees so to limit the log pollution could be useful so we don't show the same thing over and over again.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
question Further information is requested
Projects
None yet
Development

No branches or pull requests

2 participants