equinor / equinor/fusion-framework

context: ContextClient.setCurrentContext should compare context before resolving and reconsider swallowing resolve errors

Open
#5,117 0 comments 0 reactions 0 assignees View on GitHub
Dominant language
TypeScript
Stars
10
Forks
10
Avg merge
19h 40m
Merged PRs (30d)
150

Description

In `ContextClient.setCurrentContext`, when a string id is provided, the client resolves it and swallows any resolution error via `catchError(() => EMPTY)`, without comparing against the current context first:

```ts
public setCurrentContext(idOrItem?: string | ContextItem | null): void {
if (typeof idOrItem === 'string') {
// TODO - compare context
this.resolveContext(idOrItem)
// TODO should this catch error?
.pipe(catchError(() => EMPTY))
.subscribe((value) => this.setCurrentContext(value));
/** only add context if not match */
} else if (!equal(idOrItem, this.#currentContext$.value)) {
this.#currentContext$.next(idOrItem);
}
}
```

Two follow-ups:
1. Consider comparing the requested id against the current context's id before triggering a resolve, to avoid unnecessary requests (mirroring the `else` branch's equality check).
2. Decide whether silently swallowing resolution errors (`catchError(() => EMPTY)`) is the right behavior, or whether errors should be surfaced/logged.

_Originally flagged as two `// TODO` comments while resolving fusion-lint warnings on `fix/sematic-lint`._

Contributor guide

Open the contributing guide

Research direction

Start by locating ContextClient.setCurrentContext and its resolveContext implementation. Trace how current context IDs are represented and how resolution errors are handled. Define and test expected behavior for same-ID requests and failed resolution before changing either comparison or error handling.

Written by the indexing model from the issue text.

Assessment

Tech stack
typescript
Domain
frontend
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Quiet
Clarity
Needs clarification
Newbie friendliness
45/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.