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

Caching of failed responses #671

Closed
elsand opened this issue Apr 24, 2024 · 0 comments · Fixed by #684
Closed

Caching of failed responses #671

elsand opened this issue Apr 24, 2024 · 0 comments · Fixed by #684
Assignees
Labels
bug Something isn't working

Comments

@elsand
Copy link
Member

elsand commented Apr 24, 2024

Description

We're returning null/empty responses when HttpClient calls fail, causing these data to be cached. See discussion.

Reproduction

All infrastructure clients used for lookups (with the possible exception ofOrganizationRegistryClient) will return null or empty results upon any intermittent error. FusionCache will then happily cache those responses as valid results, and API callers won't be able to distinguish actual empty results with intermittent upstream failure.

Expected behavior

If the remote server is down (ie. we get some sort of socket/connection error), non-successful response codes or the returned data fails to unserialize to the expected model, an exception should be thrown. This will be caught by the FailSafe mechanism in FusionCache, which will reuse the stale data and attempt a new request after FailSafeThrottleDuration has elapsed. The actual request should use Polly with a retry (and perhaps backoff).

If no stale data is available, or if FailSafeMaxDuration is reached, the exception should bubble up and result in a 502 Bad Gateway to indicate to clients that something upstream is down. Exceptions should be logged / alerted as normally.

Actual behavior

No exceptions are thrown, and misbehaving upstream services cause empty/null results to be returned, which might cause confusion ("why is my inbox empty all of a sudden?")

@elsand elsand added the bug Something isn't working label Apr 24, 2024
@elsand elsand added this to the Pilotproduksjon milestone Apr 24, 2024
@elsand elsand self-assigned this Apr 30, 2024
elsand added a commit that referenced this issue Apr 30, 2024
… expectations (#684)

## Description

This fixes #671 by implementing a wrapper via extension methods that
causes post/get requests that don't return a successful message to throw
exceptions.

## Related Issue(s)

- #671

## Verification

- [x] **Your** code builds clean without any errors or warnings
- [x] Manual testing done (required)
- [ ] Relevant automated test added (if you find this hard, leave it and
we'll help out)

## Documentation

- [ ] Documentation is updated (either in `docs`-directory, Altinnpedia
or a separate linked PR in
[altinn-studio-docs.](https://github.com/Altinn/altinn-studio-docs), if
applicable)

---------

Co-authored-by: Ole Jørgen Skogstad <skogstad@softis.net>
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
1 participant