unraid / unraid/api

arraySubscription publishes the wrong root field and returns null events

Open
#2,056 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
TypeScript
Stars
113
Forks
22
Avg merge
10h 40m
Merged PRs (30d)
13

Description

Environment

Unraid OS Version: 7.3.2

Are you using a reverse proxy? No. Reproduced directly against the Unraid GraphQL API.

Pre-submission Checklist

  • I have verified that my Unraid OS is up to date
  • I have tested this issue by accessing my server directly (not through a reverse proxy)
  • This is not an Unraid Connect related issue

Issue Description

The arraySubscription GraphQL subscription fails when an array update is emitted because the event publisher sends the payload under array, while GraphQL resolves the subscription root field named arraySubscription.

Latest main at reproduction: 12c23d808a45e8521ded6d36bdf0c0aaf152775a.

The resolver subscribes to the array channel:

api/src/unraid-api/graph/resolvers/array/array.resolver.ts

@Subscription(() => UnraidArray)
public async arraySubscription() {
    return createSubscription(PUBSUB_CHANNEL.ARRAY);
}

The publisher emits a differently named root property:

api/src/store/listeners/array-event-listener.ts

pubsub.publish(PUBSUB_CHANNEL.ARRAY, { array });

Other working subscriptions publish an object keyed by the GraphQL subscription field, for example { systemMetricsCpu: payload } and { dockerContainerStats: stats }.

Steps to Reproduce

  1. Subscribe directly to:
    subscription { arraySubscription { id state } }
  2. Trigger an array state update that causes the disks state file listener to publish.
  3. Observe the GraphQL subscription error.

Expected Behavior

The subscription emits a non-null UnraidArray payload under arraySubscription.

Actual Behavior

The live API returns:

Cannot return null for non-nullable field Subscription.arraySubscription.

The regular array query succeeds, confirming the underlying array object is valid.

Additional Context

The relevant publisher and resolver files are unchanged between deployed API release commit f3205d978fada931da54df4255d41c07489066d9 and latest main commit 12c23d808a45e8521ded6d36bdf0c0aaf152775a.

There is currently no integration test that publishes an array event and executes the GraphQL subscription end to end.

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start with api/src/unraid-api/graph/resolvers/array/array.resolver.ts and api/src/store/listeners/array-event-listener.ts, then compare the payload keys used by the working subscriptions. Run the direct GraphQL subscription reproduction while triggering an array state update. Done means arraySubscription emits a non-null UnraidArray payload and an integration test covers the publish-and-subscribe path.

Written by the indexing model from the issue text.

Assessment

Tech stack
graphql, typescript
Domain
api, backend-api-design, testing
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Quiet
Clarity
Clearly specified
Newbie friendliness
78/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.