Skip to content

Conversation

@pinin4fjords
Copy link
Contributor

@pinin4fjords pinin4fjords commented Dec 17, 2025

Summary

This PR illustrates a potential approach to translating AWS SDK exceptions to standard Java NIO exceptions with clearer error messages. It is not intended to be merged as-is - we're looking for guidance on a better solution.

The Problem

Users see cryptic errors like:

could not validate file format of 's3://annotation-cache/snpeff_cache/': Unable to marshall request to JSON: Key cannot be empty

When they should see something like:

Access denied to S3 path - check AWS credentials and permissions

What This PR Demonstrates

  • Exception translation in lookup() and getS3ObjectMetadata() methods
  • Mapping HTTP status codes (401/403 → AccessDeniedException, 404 → NoSuchFileException)
  • Wrapping other SDK errors as IOException

⚠️ Why This Approach Is Problematic

The current implementation relies on fragile string matching to detect credential errors:

message.contains("Unable to load credentials") ||
message.contains("Unable to marshall request")

This is not a viable solution because:

  • It depends on error message text that could change between SDK versions
  • The "Unable to marshall request" pattern catches serialization errors that coincidentally appear when credentials are misconfigured - this is not a reliable indicator
  • It will misclassify errors and break unpredictably

What We Need

We're looking for guidance on how to properly detect credential and access issues from AWS SDK exceptions. Is there a more robust approach using exception types, error codes, or the SDK's error handling facilities?

Context

See issue #6668 for the full problem description. The goal is to allow downstream tools like nf-schema to distinguish access errors from other failures.

🤖 Generated with Claude Code

Translate AWS SDK exceptions to standard Java NIO exceptions with
clear, actionable error messages in S3ObjectSummaryLookup.lookup().

- 401/403 status codes -> AccessDeniedException with credential hint
- 404 status code -> NoSuchFileException
- Credential loading errors -> AccessDeniedException
- Other SDK errors -> IOException with original cause

This allows downstream tools like nf-schema to distinguish between
access errors (which can be skipped gracefully) and other validation
failures, and provides users with meaningful error messages instead
of cryptic AWS SDK exceptions.

Fixes #6668

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude Opus 4.5 <[email protected]>
Signed-off-by: Jonathan Manning <[email protected]>
@netlify
Copy link

netlify bot commented Dec 17, 2025

Deploy Preview for nextflow-docs-staging canceled.

Name Link
🔨 Latest commit 1c27949
🔍 Latest deploy log https://app.netlify.com/projects/nextflow-docs-staging/deploys/6942bcf078c8400008d517e0

@pinin4fjords pinin4fjords marked this pull request as draft December 17, 2025 14:10
pinin4fjords and others added 2 commits December 17, 2025 14:19
- Remove fragile 'Unable to marshall request' pattern matching
  (marshall errors now wrapped as IOException, not AccessDeniedException)
- Apply consistent exception handling to getS3ObjectMetadata()
- Update copyright years to 2025

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude Opus 4.5 <[email protected]>
Signed-off-by: Jonathan Manning <[email protected]>
The 'Unable to marshall request' error is a symptom of credential
issues and should be translated to AccessDeniedException so that
downstream tools like nf-schema can distinguish access errors from
other failures.

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude Opus 4.5 <[email protected]>
Signed-off-by: Jonathan Manning <[email protected]>
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.

Improve S3 filesystem error messages when credentials are missing or access is denied

2 participants