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

Review how vizarr works as of recent switch from zarr.js to zarrita.js #5

Closed
tcompa opened this issue Jul 16, 2024 · 4 comments
Closed

Comments

@tcompa
Copy link
Collaborator

tcompa commented Jul 16, 2024

The obvious question is whether a patch similar to gzuidhof/zarr.js#151 would be needed for zarrita.js as well.

@tcompa
Copy link
Collaborator Author

tcompa commented Jul 16, 2024

@zonia3000
Copy link
Collaborator

I did some tests using the new vizarr version based on zarrita.js.

Zarrita.js has a handle_response function that handles unexpected response status.

async function handle_response(
	response: Response,
): Promise<Uint8Array | undefined> {
	if (response.status === 404 || response.status === 403) {
		return undefined;
	}
	if (response.status === 200 || response.status === 206) {
		return new Uint8Array(await response.arrayBuffer());
	}
	throw new Error(
		`Unexpected response status ${response.status} ${response.statusText}`,
	);
}

However the function treats in the same way the Not Found and Forbidden status. This may be a deliberate choice, since some servers replies with 404 also for forbidden pages. This is standard, as mentioned in MDN Docs:

404 Not Found: [...] Servers may also send this response instead of 403 Forbidden to hide the existence of a resource from an unauthorized client.

So, we could proceed with this new version, modifying only vizarr to display the error message, but considering that both for 404 and for 403 we will have the following message:

Error: server replied with "Node not found: v3 array or group" when loading the resource

image

An alternative would be, in fractal-data, to use a non standard error code to notify the Forbidden case. It could be a generic 400 Bad Request or a 401 Unauthorized.

In that case the error message will be:

Error: server replied with "Unexpected response status 400 Bad Request" when loading the resource

@zonia3000
Copy link
Collaborator

In #15 I've added the changes for using the newer vizarr version, that also switched from npm to pnpm. It looks that it is mandatory to use pnpm to build the package. I suggest to install it using npm install -g pnpm.

Moreover the vizarr output folder is now called dist and not out. I've updated the information on the README.

@tcompa
Copy link
Collaborator Author

tcompa commented Aug 26, 2024

No further activity needed on this one, for the moment. We are aware that the error message may be suboptimal - as described above.

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

No branches or pull requests

2 participants