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

25 Commits

Author SHA1 Message Date
Mateusz Kwasniewski
108e15940e
fix: don't create duplicate tags on import (#3688) 2023-05-04 22:19:00 +02:00
Mateusz Kwasniewski
116db8f6d1
feat: promote toggles script (#3639) 2023-04-28 09:08:12 +02:00
Mateusz Kwasniewski
70a8ab4c47
feat: export by tags (#3635) 2023-04-27 10:22:14 +02:00
Thomas Heartman
596d7543e5
chore: remove @ts-ignore-error (#3629) 2023-04-26 17:08:55 +02:00
Thomas Heartman
0613ee0bd9
fix: add truth checks to a number of jest tests. (#3627) 2023-04-26 14:24:09 +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
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
Mateusz Kwasniewski
f1133556bd
refactor: switching to new stats calculations (#3477) 2023-04-10 09:50:39 +02:00
Jaanus Sellin
99bcd7ca5c
feat: add import export flag (#3411) 2023-03-29 09:19:33 +03:00
Mateusz Kwasniewski
2caab45801
feat: disallow clone toggle on change request enabled (#3383) 2023-03-27 13:21:50 +02:00
Mateusz Kwasniewski
9abe859e60
chore: remove export import flag (#3371) 2023-03-27 12:31:19 +02:00
Mateusz Kwasniewski
ab913228ca
refactor: read model for change request access checking (#3380) 2023-03-24 14:31:43 +01:00
Gastón Fournier
a79a76f497
refactor: test composition and other error codes (#3348)
## About the changes
Small refactor to showcase how to use [composition to validate different
aspects of the
response](https://github.com/Unleash/unleash/pull/3348/files#diff-ee4c1bd501b1195162b7a85ed6be348a665288f871abc8e74f64d94361213f9eR361-R367)
and checking [different status
codes](https://github.com/Unleash/unleash/pull/3348/files#diff-4044a5da3280ef76960bbffd5f36eccb395ac319fe58c4d59ef68a878cbb1a5dR95)
2023-03-23 16:31:05 +01:00
Gastón Fournier
af42347a7b
chore: PoC test API helper (DRY) (#3342)
## About the changes
New way of centralizing API calls while doing E2E tests to avoid repeating ourselves.
2023-03-20 10:27:19 +01:00
Gastón Fournier
7a9ea22eed
feat: project-specific segments tests and fixes (#3339)
## About the changes
- Refactored some E2E tests to use our APIs
- Added test cases for project-specific segments
- Added validation to check a project can access a specific segment
- Fixed an OpenAPI schema that was missing segments

## Discussion points
https://github.com/Unleash/unleash/pull/3339/files#r1140008992
2023-03-17 12:43:34 +01:00
Mateusz Kwasniewski
1064dfa40c
feat: project mode (#3334) 2023-03-16 15:29:52 +01:00
Mateusz Kwasniewski
481a7bc45c
fix: Missing export (#3327) 2023-03-15 17:10:36 +01:00
Mateusz Kwasniewski
ce0543c951
feat: Create project service di (#3326) 2023-03-15 16:46:41 +01:00
Gastón Fournier
1d0bc833b3
chore: refactor segments to stop depending on the implementation (#3315)
## About the changes
- Introducing ISegmentService interface to decouple from the actual
implementation
- Moving UpsertSegmentSchema to OSS to be able to use types
- Added comments where our code is coupled with segments just to
highlight and have a conversation about some use cases if needed, but
they can be removed before merging
- Removed segment service from some project features as it was not used
2023-03-15 14:58:19 +01:00
Gastón Fournier
98d462db27
chore: add a new project column to segments table (#3263)
## About the changes
Adds a migration and persistence layer with a new column
`segment_project_id` to bind a segment to a project.
2023-03-07 14:56:20 +01:00
Mateusz Kwasniewski
e15aa9795a
feat: shared event emitter (#3241) 2023-03-02 09:52:19 +01:00
Mateusz Kwasniewski
ad588fd0d2
fix: pass shared event store (#3233) 2023-03-01 14:09:52 +01:00
Gastón Fournier
90e4054c90
docs: update documentation around permissions for variants (#3195)
Co-authored-by: Thomas Heartman <thomas@getunleash.ai>
2023-02-28 14:06:24 +01:00
Mateusz Kwasniewski
909d709089
fix: db type (#3180) 2023-02-22 11:15:46 +01:00
Mateusz Kwasniewski
3800877be1
feat: drop full- for import/validate (#3168) 2023-02-21 10:15:57 +01:00