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

[everything] Unintuitive / misleading resource indexing #475

Open
PederHP opened this issue Jan 4, 2025 · 0 comments
Open

[everything] Unintuitive / misleading resource indexing #475

PederHP opened this issue Jan 4, 2025 · 0 comments
Labels
bug Something isn't working

Comments

@PederHP
Copy link

PederHP commented Jan 4, 2025

Describe the bug
The everything server's resource indexing is counterintuitive. While the array index starts at 0, the resource numbering in URIs starts at 1, which leads to confusing behavior where:

  • Resource at index 0 is accessed via URI "test://static/resource/1"
  • Resource at index 1 is accessed via URI "test://static/resource/2"
    etc.

From the server code:

const ALL_RESOURCES: Resource[] = Array.from({ length: 100 }, (_, i) => ({
    const url = `test://static/resource/${i + 1}`;
    if (i % 2 === 0) {
        // index 0 (first resource) is text
        // index 2 (third resource) is text
        // etc.

This means even-indexed resources (0,2,4...) are text, but they map to odd-numbered URIs (1,3,5...).

To Reproduce
Make a ListResources request, then try to read the first text resource:

  1. List resources:
{
    "jsonrpc": "2.0",
    "id": 1,
    "method": "resources/list"
}
  1. Get first text resource (index 0):
{
    "jsonrpc": "2.0",
    "id": 2,
    "method": "resources/read",
    "params": {
        "uri": "test://static/resource/1"
    }
}

Expected behavior
Either:

  1. Align the indexing so resource numbers in URIs match array indices (preferred)
  2. Or document this behavior clearly to prevent confusion
@PederHP PederHP added the bug Something isn't working label Jan 4, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

1 participant