1
0
mirror of https://github.com/Unleash/unleash.git synced 2024-12-22 19:07:54 +01:00
Commit Graph

8277 Commits

Author SHA1 Message Date
andreas-unleash
1ccbbfeb57
Feat: project default strategy (#3644)
<!-- Thanks for creating a PR! To make it easier for reviewers and
everyone else to understand what your changes relate to, please add some
relevant content to the headings below. Feel free to ignore or delete
sections that you don't think are relevant. Thank you! ❤️ -->

Adds default strategy to project environment link table

## About the changes
<!-- Describe the changes introduced. What are they and why are they
being introduced? Feel free to also add screenshots or steps to view the
changes if they're visual. -->

<!-- Does it close an issue? Multiple? -->
Closes #
[1-876](https://linear.app/unleash/issue/1-876/default-strategy-backend)

<!-- (For internal contributors): Does it relate to an issue on public
roadmap? -->
<!--
Relates to [roadmap](https://github.com/orgs/Unleash/projects/10) item:
#
-->

### Important files
<!-- PRs can contain a lot of changes, but not all changes are equally
important. Where should a reviewer start looking to get an overview of
the changes? Are any files particularly important? -->


## Discussion points
<!-- Anything about the PR you'd like to discuss before it gets merged?
Got any questions or doubts? -->

---------

Signed-off-by: andreas-unleash <andreas@getunleash.ai>
2023-04-28 14:59:04 +03:00
GitHub Actions Bot
e378793de5 5.1.0-beta.11 2023-04-28 11:57:22 +00:00
Nuno Góis
9df9095b1f
feat: demo small UI adjustments (#3653)
https://linear.app/unleash/issue/2-975/small-ui-adjustments

Adds some small UI adjustments we identified in the meantime:
 - "Get Unleash" -> "Get started" in the top banner;
 - Topics list header is now the same color as the top banner;
- Added `focus` capabilities to steps, added it to the appropriate
steps;
 - No longer closes tooltip when clicked when using `anyClick`;
 - Reversed the topics list header arrow rotation;

Relates to [roadmap](https://github.com/orgs/Unleash/projects/10) item:
#3537


![image](https://user-images.githubusercontent.com/14320932/235139390-a40db29d-befe-44f9-9f61-a0ad120b7251.png)
2023-04-28 11:54:58 +00:00
GitHub Actions Bot
e7dec9a8a4 5.1.0-beta.10 2023-04-28 11:50:59 +00:00
Jaanus Sellin
2a6cfc434f
fix: fix bulk removal of tags (#3651) 2023-04-28 14:49:34 +03:00
Mateusz Kwasniewski
10fee99467
Update how-to-synchronize-unleash-instances.md 2023-04-28 13:28:19 +02:00
Mateusz Kwasniewski
96e3e43188
docs: unleash instance synchronization (#3652) 2023-04-28 13:23:50 +02:00
Thomas Heartman
b815fa1a9d
docs: add migration guide entry for v4 -> v5 (#3650)
This lists the breaking changes between the versions to make it easier
(and safer) for users to upgrade
2023-04-28 13:10:30 +02:00
GitHub Actions Bot
178f4ff292 5.1.0-beta.9 2023-04-28 10:26:15 +00:00
Mateusz Kwasniewski
c8bce08e94
feat: remove project overview flag (#3648) 2023-04-28 12:25:59 +02:00
GitHub Actions Bot
8e75f14a29 5.1.0-beta.8 2023-04-28 09:21:53 +00:00
Christopher Kolstad
f1db90d38c
fix: correct error for missing context field (#3647)
When adding a strategy using a context field that did not exist, we
threw an unknown error.

This changes to throw NotFoundError so that our users can better know
what they did wrong.
2023-04-28 09:21:32 +00:00
GitHub Actions Bot
a984de7941 5.1.0-beta.7 2023-04-28 08:18:27 +00:00
Jaanus Sellin
383aa3dde4
feat: remove bulk operations flag (#3643) 2023-04-28 11:18:03 +03:00
GitHub Actions Bot
108eee91f1 5.1.0-beta.6 2023-04-28 07:08:34 +00:00
Mateusz Kwasniewski
116db8f6d1
feat: promote toggles script (#3639) 2023-04-28 09:08:12 +02:00
renovate[bot]
b18d62521f
chore(deps): update dependency @swc/core to v1.3.52 (#3641)
[![Mend
Renovate](https://app.renovatebot.com/images/banner.svg)](https://renovatebot.com)

This PR contains the following updates:

| Package | Change | Age | Adoption | Passing | Confidence |
|---|---|---|---|---|---|
| [@swc/core](https://swc.rs)
([source](https://togithub.com/swc-project/swc)) | [`1.3.51` ->
`1.3.52`](https://renovatebot.com/diffs/npm/@swc%2fcore/1.3.51/1.3.52) |
[![age](https://badges.renovateapi.com/packages/npm/@swc%2fcore/1.3.52/age-slim)](https://docs.renovatebot.com/merge-confidence/)
|
[![adoption](https://badges.renovateapi.com/packages/npm/@swc%2fcore/1.3.52/adoption-slim)](https://docs.renovatebot.com/merge-confidence/)
|
[![passing](https://badges.renovateapi.com/packages/npm/@swc%2fcore/1.3.52/compatibility-slim/1.3.51)](https://docs.renovatebot.com/merge-confidence/)
|
[![confidence](https://badges.renovateapi.com/packages/npm/@swc%2fcore/1.3.52/confidence-slim/1.3.51)](https://docs.renovatebot.com/merge-confidence/)
|

---

### Release Notes

<details>
<summary>swc-project/swc</summary>

###
[`v1.3.52`](https://togithub.com/swc-project/swc/blob/HEAD/CHANGELOG.md#&#8203;1352---2023-04-19)

[Compare
Source](https://togithub.com/swc-project/swc/compare/v1.3.51...v1.3.52)

##### Bug Fixes

- **(es/minifier)** Fix a inliner bug related to `Script`
([#&#8203;7288](https://togithub.com/swc-project/swc/issues/7288))
([0aab90c](0aab90c005))

- **(es/resolver)** Hoist parameter in arrow and constructor
([#&#8203;7292](https://togithub.com/swc-project/swc/issues/7292))
([7a00f2e](7a00f2e954))

##### Performance

- **(es/react)** Don't use regex
([#&#8203;7284](https://togithub.com/swc-project/swc/issues/7284))
([248fd37](248fd374e6))

- **(preset-env)** Update static map
([#&#8203;7293](https://togithub.com/swc-project/swc/issues/7293))
([bc83cb2](bc83cb2ecf))

##### Build

- **(cargo)** Bump up wasmer
([#&#8203;7294](https://togithub.com/swc-project/swc/issues/7294))
([39d415c](39d415cc16))

</details>

---

### Configuration

📅 **Schedule**: Branch creation - At any time (no schedule defined),
Automerge - At any time (no schedule defined).

🚦 **Automerge**: Enabled.

♻ **Rebasing**: Whenever PR becomes conflicted, or you tick the
rebase/retry checkbox.

🔕 **Ignore**: Close this PR and you won't be reminded about this update
again.

---

- [ ] <!-- rebase-check -->If you want to rebase/retry this PR, check
this box

---

This PR has been generated by [Mend
Renovate](https://www.mend.io/free-developer-tools/renovate/). View
repository job log
[here](https://app.renovatebot.com/dashboard#github/Unleash/unleash).

<!--renovate-debug:eyJjcmVhdGVkSW5WZXIiOiIzNS42My4xIiwidXBkYXRlZEluVmVyIjoiMzUuNjMuMSJ9-->

Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
2023-04-28 05:25:46 +00:00
renovate[bot]
a309105553
chore(deps): update dependency sass to v1.62.0 (#3613)
[![Mend
Renovate](https://app.renovatebot.com/images/banner.svg)](https://renovatebot.com)

This PR contains the following updates:

| Package | Change | Age | Adoption | Passing | Confidence |
|---|---|---|---|---|---|
| [sass](https://togithub.com/sass/dart-sass) | [`1.58.3` ->
`1.62.0`](https://renovatebot.com/diffs/npm/sass/1.58.3/1.62.0) |
[![age](https://badges.renovateapi.com/packages/npm/sass/1.62.0/age-slim)](https://docs.renovatebot.com/merge-confidence/)
|
[![adoption](https://badges.renovateapi.com/packages/npm/sass/1.62.0/adoption-slim)](https://docs.renovatebot.com/merge-confidence/)
|
[![passing](https://badges.renovateapi.com/packages/npm/sass/1.62.0/compatibility-slim/1.58.3)](https://docs.renovatebot.com/merge-confidence/)
|
[![confidence](https://badges.renovateapi.com/packages/npm/sass/1.62.0/confidence-slim/1.58.3)](https://docs.renovatebot.com/merge-confidence/)
|

---

### Release Notes

<details>
<summary>sass/dart-sass</summary>

###
[`v1.62.0`](https://togithub.com/sass/dart-sass/blob/HEAD/CHANGELOG.md#&#8203;1620)

[Compare
Source](https://togithub.com/sass/dart-sass/compare/1.61.0...1.62.0)

- Deprecate the use of multiple `!global` or `!default` flags on the
same
    variable. This deprecation is named `duplicate-var-flags`.

- Allow special numbers like `var()` or `calc()` in the global
functions:
`grayscale()`, `invert()`, `saturate()`, and `opacity()`. These are also
native CSS `filter` functions. This is in addition to number values
which were
    already allowed.

- Fix a cosmetic bug where an outer rule could be duplicated after
nesting was
    resolved, instead of re-using a shared rule.

###
[`v1.61.0`](https://togithub.com/sass/dart-sass/blob/HEAD/CHANGELOG.md#&#8203;1610)

[Compare
Source](https://togithub.com/sass/dart-sass/compare/1.60.0...1.61.0)

- **Potentially breaking change:** Drop support for End-of-Life Node.js
12.

- Fix remaining cases for the performance regression introduced in
1.59.0.

##### Embedded Sass

- The JS embedded host now loads files from the working directory when
using the
    legacy API.

###
[`v1.60.0`](https://togithub.com/sass/dart-sass/blob/HEAD/CHANGELOG.md#&#8203;1600)

[Compare
Source](https://togithub.com/sass/dart-sass/compare/1.59.3...1.60.0)

- Add support for the `pi`, `e`, `infinity`, `-infinity`, and `NaN`
constants in
calculations. These will be interpreted as the corresponding numbers.

- Add support for unknown constants in calculations. These will be
interpreted
    as unquoted strings.

- Serialize numbers with value `infinity`, `-infinity`, and `NaN` to
`calc()`
expressions rather than CSS-invalid identifiers. Numbers with complex
units
    still can't be serialized.

###
[`v1.59.3`](https://togithub.com/sass/dart-sass/blob/HEAD/CHANGELOG.md#&#8203;1593)

[Compare
Source](https://togithub.com/sass/dart-sass/compare/1.59.2...1.59.3)

-   Fix a performance regression introduced in 1.59.0.

- The NPM release of 1.59.0 dropped support for Node 12 without actually
indicating so in its pubspec. This release temporarily adds back support
so
that the latest Sass version that declares it supports Node 12 actually
does
so. However, Node 12 is now end-of-life, so we will drop support for it
    properly in an upcoming release.

###
[`v1.59.2`](https://togithub.com/sass/dart-sass/blob/HEAD/CHANGELOG.md#&#8203;1592)

[Compare
Source](https://togithub.com/sass/dart-sass/compare/1.59.1...1.59.2)

-   No user-visible changes.

###
[`v1.59.1`](https://togithub.com/sass/dart-sass/blob/HEAD/CHANGELOG.md#&#8203;1591)

[Compare
Source](https://togithub.com/sass/dart-sass/compare/1.59.0...1.59.1)

-   No user-visible changes.

###
[`v1.59.0`](https://togithub.com/sass/dart-sass/blob/HEAD/CHANGELOG.md#&#8203;1590)

[Compare
Source](https://togithub.com/sass/dart-sass/compare/1.58.3...1.59.0)

##### Command Line Interface

- Added a new `--fatal-deprecation` flag that lets you treat a
deprecation
    warning as an error. You can pass an individual deprecation ID
    (e.g. `slash-div`) or you can pass a Dart Sass version to treat all
    deprecations initially emitted in that version or earlier as errors.

- New `--future-deprecation` flag that lets you opt into warning for use
of
certain features that will be deprecated in the future. At the moment,
the
only option is `--future-deprecation=import`, which will emit warnings
for
Sass `@import` rules, which are not yet deprecated, but will be in the
future.

##### Dart API

- New `Deprecation` enum, which contains the different current and
future
    deprecations used by the new CLI flags.

- The `compile` methods now take in `fatalDeprecations` and
`futureDeprecations`
    parameters, which work similarly to the CLI flags.

</details>

---

### Configuration

📅 **Schedule**: Branch creation - At any time (no schedule defined),
Automerge - At any time (no schedule defined).

🚦 **Automerge**: Enabled.

♻ **Rebasing**: Whenever PR becomes conflicted, or you tick the
rebase/retry checkbox.

🔕 **Ignore**: Close this PR and you won't be reminded about this update
again.

---

- [ ] <!-- rebase-check -->If you want to rebase/retry this PR, check
this box

---

This PR has been generated by [Mend
Renovate](https://www.mend.io/free-developer-tools/renovate/). View
repository job log
[here](https://app.renovatebot.com/dashboard#github/Unleash/unleash).

<!--renovate-debug:eyJjcmVhdGVkSW5WZXIiOiIzNS41OC4wIiwidXBkYXRlZEluVmVyIjoiMzUuNTguMCJ9-->

Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
2023-04-28 01:26:01 +00:00
GitHub Actions Bot
6c84777e06 5.1.0-beta.5 2023-04-27 13:51:58 +00:00
Thomas Heartman
3d31d1b934
fix: ensure that the owaspvalidationerrors always contain all errors (#3638)
## What

This fixes a bug where the owasp validation response that came back from
the server no longer contained all its validation errors. This caused
the UI to slightly break and for the password validation box not to
update correctly.

This is a quick fix (but with tests!). I'm working on a better design
for this on the side, but it seemed pertinent to get this out ASAP.
2023-04-27 15:51:37 +02:00
GitHub Actions Bot
7f0a8362cb 5.1.0-beta.4 2023-04-27 13:12:32 +00:00
Nuno Góis
3c48171c78
feat: add user tracking to demo (#3637)
https://linear.app/unleash/issue/2-946/explore-and-implement-options-for-user-tracking

Adds user tracking to the interactive demo, so we can measure how users
are using this feature and improve it in the feature.

## Events

- **start** - When the user starts the demo by clicking on the "Try
Unleash Demo" button;
- **finish** - When the user finishes the demo by seeing the "You
finished the demo" dialog;
- **restart** - When the user decides to restart the demo on the "You
finished the demo" dialog;
- **close** - When the user closes a demo dialog;
- **topic** - In what topic this happened (topic title, can also be
`start` if user closes on the start dialog);
- **step** - In what step this happened (step number, `1` would mean
first step);
- **start_topic** - When the user decides to start a specific topic by
clicking it in the list;
  - **topic** - What topic was clicked (topic title);
- **ask_questions** - When the user decides to ask questions by clicking
the appropriate option in the top banner;
- **see_plans** - When the user decides to see the plans by clicking the
appropriate option in the top banner;
- **plan** - What plan was clicked (one of: `open_source`, `pro`,
`enterprise` or `compare_plans`);
- **open_demo_web** - User decided to open the demo website using the
link on the start dialog;
- **view_demo_link** - User decided to open the start dialog again on
the bottom of the topics list;

Relates to [roadmap](https://github.com/orgs/Unleash/projects/10) item:
#3537
2023-04-27 14:12:02 +01:00
GitHub Actions Bot
9deff83d74 5.1.0-beta.3 2023-04-27 08:50:12 +00:00
Christopher Kolstad
d7b1d1c9ce
fix: Updated cypress API usage to stop using deprecated API (#3636) 2023-04-27 08:49:55 +00:00
GitHub Actions Bot
e98d839992 5.1.0-beta.2 2023-04-27 08:22:36 +00:00
Mateusz Kwasniewski
70a8ab4c47
feat: export by tags (#3635) 2023-04-27 10:22:14 +02:00
GitHub Actions Bot
4f12361c94 5.1.0-beta.1 2023-04-27 07:15:37 +00:00
Nuno Góis
3599e7478c
feat: demo ui-ux improvements (#3634)
https://linear.app/unleash/issue/2-914/improve-demo-guide-uiux

Includes a big batch of UI/UX improvements, including but not limited
to:

- Updating steps text;
- Improve behavior of intro step dialogs (use normal dialogs);
- Improve overall design;
- Improve escape key and backdrop click behaviors;
- Add plans dialog;
- Add sticky demo banner;
- Assume `demo-app` project and `dev` environment to better fit our demo
instance;
- Misc fixes and refactors;

Relates to [roadmap](https://github.com/orgs/Unleash/projects/10) item:
#3537


![image](https://user-images.githubusercontent.com/14320932/234637210-1936fd48-ce40-4980-81ae-f1fe64e65545.png)
2023-04-27 08:15:17 +01:00
GitHub Actions Bot
21640481ab 5.1.0-beta.0 2023-04-26 15:09:16 +00:00
Thomas Heartman
596d7543e5
chore: remove @ts-ignore-error (#3629) 2023-04-26 17:08:55 +02:00
GitHub Actions Bot
2010e5d345 5.0.0 2023-04-26 14:41:06 +00:00
GitHub Actions Bot
7967a9bfb9 5.0.0-beta.2 2023-04-26 14:08:04 +00:00
Mateusz Kwasniewski
251fb86702
chore: mergify (#3631) 2023-04-26 16:07:34 +02:00
andreas-unleash
2667e55d4a
chore: remove projectScopedStickinessFlag (#3620)
<!-- Thanks for creating a PR! To make it easier for reviewers and
everyone else to understand what your changes relate to, please add some
relevant content to the headings below. Feel free to ignore or delete
sections that you don't think are relevant. Thank you! ❤️ -->

## About the changes
<!-- Describe the changes introduced. What are they and why are they
being introduced? Feel free to also add screenshots or steps to view the
changes if they're visual. -->

<!-- Does it close an issue? Multiple? -->
Closes #

<!-- (For internal contributors): Does it relate to an issue on public
roadmap? -->
<!--
Relates to [roadmap](https://github.com/orgs/Unleash/projects/10) item:
#
-->

### Important files
<!-- PRs can contain a lot of changes, but not all changes are equally
important. Where should a reviewer start looking to get an overview of
the changes? Are any files particularly important? -->


## Discussion points
<!-- Anything about the PR you'd like to discuss before it gets merged?
Got any questions or doubts? -->

Signed-off-by: andreas-unleash <andreas@getunleash.ai>
2023-04-26 17:07:09 +03:00
Thomas Heartman
a7213bf70b
Return details arrays on all errors. (#3630)
We used to use the `details` property to return a list of errors on a
lot of our errors, but the new format doesn't do this anymore. However,
some of the admin UI still expects this to be present, even when the
data could go into `message`. So for now, the solution is to duplicate
the data and put it both in `message` and in the first element of the
`details` list. If the error has its own details lust (such as openapi
errors etc), then they will overwrite this default `details` property.
2023-04-26 15:41:43 +02:00
GitHub Actions Bot
33dce40773 5.0.0-beta.1 2023-04-26 12:24:31 +00:00
Thomas Heartman
0613ee0bd9
fix: add truth checks to a number of jest tests. (#3627) 2023-04-26 14:24:09 +02:00
Mateusz Kwasniewski
9cdc3190bc
5.0.0-beta.0 (#3628) 2023-04-26 13:51:27 +02:00
Christopher Kolstad
1b248a03e9
docs: Metrics tag openapi docs (#3572)
I've copied most of the descriptions from what we did for batch metrics
under the Edge tag, however there are a couple of top level descriptions
that are "fine" but I'm definitely open to suggestions.

---------

Co-authored-by: Thomas Heartman <thomas@getunleash.ai>
2023-04-26 12:10:57 +02:00
Tymoteusz Czech
3bb09c5ce4
Disable and enable strategies - frontend (#3582)
Signed-off-by: andreas-unleash <andreas@getunleash.ai>
Co-authored-by: andreas-unleash <andreas@getunleash.ai>
2023-04-26 11:41:24 +02:00
GitHub Actions Bot
1e3f652311 4.23.0-beta.84 2023-04-26 09:07:15 +00:00
andreas-unleash
2dc24ada8e
fix: migration failure when sessionId exists (#3624) (#3625)
<!-- Thanks for creating a PR! To make it easier for reviewers and
everyone else to understand what your changes relate to, please add some
relevant content to the headings below. Feel free to ignore or delete
sections that you don't think are relevant. Thank you! ❤️ -->
Back-porting the migration fix
## About the changes
<!-- Describe the changes introduced. What are they and why are they
being introduced? Feel free to also add screenshots or steps to view the
changes if they're visual. -->

<!-- Does it close an issue? Multiple? -->
Closes #

<!-- (For internal contributors): Does it relate to an issue on public
roadmap? -->
<!--
Relates to [roadmap](https://github.com/orgs/Unleash/projects/10) item:
#
-->

### Important files
<!-- PRs can contain a lot of changes, but not all changes are equally
important. Where should a reviewer start looking to get an overview of
the changes? Are any files particularly important? -->


## Discussion points
<!-- Anything about the PR you'd like to discuss before it gets merged?
Got any questions or doubts? -->

<!-- Thanks for creating a PR! To make it easier for reviewers and
everyone else to understand what your changes relate to, please add some
relevant content to the headings below. Feel free to ignore or delete
sections that you don't think are relevant. Thank you! ❤️ -->

## About the changes
<!-- Describe the changes introduced. What are they and why are they
being introduced? Feel free to also add screenshots or steps to view the
changes if they're visual. -->

<!-- Does it close an issue? Multiple? -->
Closes #

<!-- (For internal contributors): Does it relate to an issue on public
roadmap? -->
<!--
Relates to [roadmap](https://github.com/orgs/Unleash/projects/10) item:
#
-->

### Important files
<!-- PRs can contain a lot of changes, but not all changes are equally
important. Where should a reviewer start looking to get an overview of
the changes? Are any files particularly important? -->


## Discussion points
<!-- Anything about the PR you'd like to discuss before it gets merged?
Got any questions or doubts? -->

Signed-off-by: andreas-unleash <andreas@getunleash.ai>
2023-04-26 09:00:13 +00:00
GitHub Actions Bot
3f73b53452 4.23.0-beta.83 2023-04-26 08:56:14 +00:00
Simon Hornby
9521c452c5
chore: move google auth ui behind flag (#3606)
Moves the access tab for Google Auth behind a flag. The elements
are still accessible but hidden by default so this is a soft change.
This is a deprecated feature and is on its way out.
2023-04-26 10:55:55 +02:00
Christopher Kolstad
1fdf68eeec
task: removes deprecated feature api (#3609)
### What
We've had this marked as deprecated through our v4, this PR removes it.

### Worth noting
This updates the deprecation notices with removal notices in the
documentation as well.

### Considerations
The tags API is still located under
/api/admin/features/{featureName}/tags. It should be moved to
/api/admin/projects/{project}/features/{featureName}/tags. I vote we do
that in a separate PR, we'd probably also need to deprecate the existing
tags endpoints for v5 and remove in v6. We could use 308s to signify
that they are moved.

---------

Co-authored-by: Thomas Heartman <thomas@getunleash.ai>
2023-04-26 10:45:00 +02:00
Mateusz Kwasniewski
7eda493e8e
docs: skip CR also works in the UI (#3518) 2023-04-26 08:49:34 +02:00
GitHub Actions Bot
8df65d2d39 4.23.0-beta.82 2023-04-26 06:39:11 +00:00
Thomas Heartman
0a613de308
fix: broken feature.e2e test + make error message clearer (#3623)
This PR fixes a broken e2e test by relaxing what it checks for. It must
have been developed in parallel so that the test wasn't included before
merging into main.
2023-04-26 06:38:53 +00:00
GitHub Actions Bot
b2bb5502b4 4.23.0-beta.81 2023-04-25 13:41:04 +00:00
Thomas Heartman
2765ae2c70
feat: unify error responses (#3607)
This PR implements the first version of a suggested unification (and
documentation) of the errors that we return from the API today.

The goal is for this to be the first step towards the error type defined
in this internal [linear
task](https://linear.app/unleash/issue/1-629/define-the-error-type
'Define the new API error type').

## The state of things today

As things stand, we currently have no (or **very** little) documentation
of the errors that are returned from the API. We mention error codes,
but never what the errors may contain.

Second, there is no specified format for errors, so what they return is
arbitrary, and based on ... Who knows? As a result, we have multiple
different errors returned by the API depending on what operation you're
trying to do. What's more, with OpenAPI validation in the mix, it's
absolutely possible for you to get two completely different error
objects for operations to the same endpoint.

Third, the errors we do return are usually pretty vague and don't really
provide any real help to the user. "You don't have the right
permissions". Great. Well what permissions do I need? And how would I
know? "BadDataError". Sick. Why is it bad?

... You get it.

## What we want to achieve

The ultimate goal is for error messages to serve both humans and
machines. When the user provides bad data, we should tell them what
parts of the data are bad and what they can do to fix it. When they
don't have the right permissions, we should tell them what permissions
they need.

Additionally, it would be nice if we could provide an ID for each error
instance, so that you (or an admin) can look through the logs and locate
he incident.

## What's included in **this** PR?

This PR does not aim to implement everything above. It's not intended to
magically fix everything. Its goal is to implement the necessary
**breaking** changes, so that they can be included in v5. Changing error
messages is a slightly grayer area than changing APIs directly, but
changing the format is definitely something I'd consider breaking.

So this PR:

- defines a minimal version of the error type defined in the [API error
definition linear
task](https://linear.app/unleash/issue/1-629/define-the-error-type).
- aims to catch all errors we return today and wrap them in the error
type
-   updates tests to match the new expectations.

An important point: because we are cutting v5 very soon and because work
for this wasn't started until last week, the code here isn't necessarily
very polished. But it doesn't need to be. The internals can be as messy
as we want, as long as the API surface is stable.

That said, I'm very open to feedback about design and code completeness,
etc, but this has intentionally been done quickly.

Please also see my inline comments on the changes for more specific
details.

### Proposed follow-ups

As mentioned, this is the first step to implementing the error type. The
public API error type only exposes `id`, `name`, and `message`. This is
barely any more than most of the previous messages, but they are now all
using the same format. Any additional properties, such as `suggestion`,
`help`, `documentationLink` etc can be added as features without
breaking the current format. This is an intentional limitation of this
PR.

Regarding additional properties: there are some error responses that
must contain extra properties. Some of these are documented in the types
of the new error constructor, but not all. This includes `path` and
`type` properties on 401 errors, `details` on validation errors, and
more.

Also, because it was put together quickly, I don't yet know exactly how
we (as developers) would **prefer** to use these new error messages
within the code, so the internal API (the new type, name, etc), is just
a suggestion. This can evolve naturally over time if (based on feedback
and experience) without changing the public API.

## Returning multiple errors

Most of the time when we return errors today, we only return a single
error (even if many things are wrong). AJV, the OpenAPI integration we
use does have a setting that allows it to return all errors in a request
instead of a single one. I suggest we turn that on, but that we do it in
a separate PR (because it updates a number of other snapshots).

When returning errors that point to `details`, the objects in the
`details` now contain a new `description` property. This "deprecates"
the `message` property. Due to our general deprecation policy, this
should be kept around for another full major and can be removed in v6.

```json
{
  "name": "BadDataError",
  "message": "Something went wrong. Check the `details` property for more information."
  "details": [{
    "message": "The .params property must be an object. You provided an array.",
    "description": "The .params property must be an object. You provided an array.",
  }]
}
```
2023-04-25 13:40:46 +00:00