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

1043 Commits

Author SHA1 Message Date
Mateusz Kwasniewski
32ae15741c
refactor: read project ids in memory (#3965) 2023-06-13 10:12:14 +02:00
Gastón Fournier
818b8e7813
fix: feature not found in project yields 404 (#3958)
## About the changes
When a feature is not found in a project we should fail with a NotFound
error. If the feature belongs to a different project, it should not be a
permission issue, because the user might not be aware (lack of
permissions/visibility) of that other project, so even in this case the
error should be NotFound (this also works if we ever allow the same
feature name in different projects)

Fixes #3726

---------

Co-authored-by: Thomas Heartman <thomas@getunleash.ai>
2023-06-12 15:07:18 +02:00
Christopher Kolstad
7003351b35
docs: Health check endpoint (#3959)
### What
Adds documentation for the health check endpoint.

---------

Co-authored-by: Thomas Heartman <thomas@getunleash.ai>
2023-06-12 12:56:45 +00:00
Mateusz Kwasniewski
7b8b6bceaf
feat: walking skeleton of the advanced playground (#3949) 2023-06-12 11:01:52 +02:00
Gastón Fournier
4e0678dfb1
fix: allow empty appName as it may come in the url (#3953)
## About the changes
Edit application under
https://app.unleash-hosted.com/demo/applications/test-app is currently
not working as the appName is expected to come in the request body, but
it's actually part of the url. We have two options here:
1. We change the UI to adapt to the expectations of the request by
adding appName to the request body (and eventually removing appName from
the URL, which would be a breaking change)
2. We remove the restriction of only sending the appName in the body and
take the one that comes in the URL. We have a validation that verifies
that at least one of the two sets the appName
([here](e376088668/src/lib/services/client-metrics/instance-service.ts (L208))
we validate using [this
schema](e376088668/src/lib/services/client-metrics/schema.ts (L55-L70)))

In terms of REST API, we can assume that the appName will be present in
the resource `/api/admin/metrics/applications` (an endpoint we don't
have), but when we're updating an application we should refer to that
application by its URL: `/api/admin/metrics/applications/<appName>` and
the presence of an appName in the body might indicate that we're trying
to change the name of the application (something we currently not
support)

Based on the above, I believe going with the second option is best, as
it adheres to REST principles and does not require a breaking change.
Despite that, we only support updating applications as the creation is
done from metrics ingestion

Fixes: #3580
2023-06-12 10:15:00 +02:00
Jaanus Sellin
9f0d94287e
feat: context field usage frontend (#3938) 2023-06-12 10:55:58 +03:00
Ivar Conradi Østhus
1bc130b7f0
fix: add createdAt in projects API response (#3929)
This PR adds the "createdAt" field to the /api/projects response, so
that we are compliant with the schema.
2023-06-09 14:18:38 +00:00
Jaanus Sellin
ea21c753bd
fix: fix variant metrics (#3947) 2023-06-09 12:48:32 +00:00
Mateusz Kwasniewski
0101491a83
refactor: playground in feature oriented architecture (#3942) 2023-06-09 12:55:54 +02:00
Jaanus Sellin
ec6e4d70b5
feat: context field usage backend (#3921) 2023-06-09 12:00:17 +03:00
Thomas Heartman
51d73f67a3
fix: propagate http-errors as they are (#3922)
This PR aims to handle the increased log alarm volume seen by the SREs.

It appears that we get a large number of alarms because a client
disconnects early from the front-end API. These errors are then
converted into 500s because of missing handling. These errors appear to
be caused by the `http-errors` library in a dependency.

We also introduced a log line whenever we see errors now a while back,
and I don't think we need this logging (I was also the one who
introduced it).

The changes in this PR are specifically:
- When converting from arbitrary errors, give `BadRequestError` a 400
status code, not a 500.
- Add a dependency on `http-errors` (which is already a transitive
dependency because of the body parser) and use that to check whether an
error is an http-error.
- If an error is an http error, then propagate it to the user with the
status code and message.
- Remove warning logs when an error occurs. This was introduced to make
it easier to correlate an API error and the logs, but the system hasn't
been set up for that (yet?), so it's just noise now.
- When logging errors as errors, only do that if their status code would
be 500.
2023-06-08 13:14:53 +02:00
Mateusz Kwasniewski
3d344509a8
feat: generate object combinations (#3920) 2023-06-07 15:51:44 +00:00
Thomas Heartman
03dd7b6863
chore: clarify error logs (#3915)
This change makes the logs that happen when we encounter an error a
little bit clearer. It logs the error message before the error ID and
also logs the full serialized message just in case.
2023-06-07 12:11:34 +00:00
Thomas Heartman
24aea5f00e
chore: improve joi errors (#3836)
This PR improves our handling of internal Joi errors, to make them more
sensible to the end user. It does that by providing a better description
of the errors and by telling the user what they value they provided was.

Previous conversion:
```json
{
  "id": "705a8dc0-1198-4894-9015-f1e5b9992b48",
  "name": "BadDataError",
  "message": "\"value\" must contain at least 1 items",
  "details": [
    {
      "message": "\"value\" must contain at least 1 items",
      "description": "\"value\" must contain at least 1 items"
    }
  ]
}
```

New conversion:
```json
{
  "id": "87fb4715-cbdd-48bb-b4d7-d354e7d97380",
  "name": "BadDataError",
  "message": "Request validation failed: your request body contains invalid data. Refer to the `details` list for more information.",
  "details": [
    {
      "description": "\"value\" must contain at least 1 items. You provided [].",
      "message": "\"value\" must contain at least 1 items. You provided []."
    }
  ]
}
```

## Restructuring

This PR moves some code out of `unleash-error.ts` and into a new file.
The purpose of this is twofold:
1. avoid circular dependencies (we need imports from both UnleashError
and BadDataError)
2. carve out a clearer separation of concerns, keeping `unleash-error` a
little more focused.
2023-06-07 08:29:36 +00:00
Thomas Heartman
08834a7250
chore: lower log-level for unexpected errors (#3837)
This change lowers the log level from warning to debug for when we see
unexpected error types.

Right now this triggers for Joi errors, which we still rely on pretty
heavily. Lowering this should clear up logs for most users.
2023-06-07 09:37:40 +02:00
Jaanus Sellin
0efaa346c4
feat: usage on context fields in list (#3906) 2023-06-06 13:59:41 +03:00
Mateusz Kwasniewski
5ec59c6e92
feat: change own password confirmation (#3894) 2023-06-05 11:58:25 +02:00
Mateusz Kwasniewski
b0a003ea58
feat: disable notifications flag (#3874) 2023-05-29 08:28:47 +02:00
Mateusz Kwasniewski
5534e4deeb
fix: remove consecutive slashes (#3882)
A small middleware who will rewrite potential dual slashes to a single slash.
2023-05-27 16:16:51 +00:00
Christopher Kolstad
52904ee038
fix: reject unauthorized client requests (#3881)
If apiTokens are enabled breaks middleware chain with a 401 if no token
is found for requests to client and frontend apis. Previously the
middleware allowed the chain to process.

Removes the regex search for multiple slashes, and instead configures
the apiTokenMiddleware to reject unauthorized requests.
2023-05-27 16:29:54 +02:00
Christopher Kolstad
3d872cf7a2
security: Reject multiple successive slashes in path (#3880) 2023-05-27 14:31:44 +02:00
Jaanus Sellin
f73d36fda3
feat: add usage of segment in list (#3853) 2023-05-26 14:37:00 +03:00
Ivar Conradi Østhus
49722d5c48
fix: use correct event type for maxRevisionId (#3870)
We had a small typo where we looked for `segment-update` event instead
of `segment-updated`. Changed to use the event constant.
2023-05-25 23:00:08 +02:00
Christopher Kolstad
3409b0c5a0
task: Add Unit test result check task (#3695)
After a Team Retro, one of our squads felt like we needed more data on
our test suites. This is the first effort to make our test results
easier to grab. It uses the test-reporter action to add a github check
to our main build and PR builds with our test results.

This at least should make it easier to parse which tests are failing.
However, it does not give us trends. So it does not yet make it easier
to decide which tests are flaky just from a quick view.

---------

Co-authored-by: Gastón Fournier <gaston@getunleash.io>
2023-05-25 11:03:54 +00:00
Mateusz Kwasniewski
78715e3374
docs: maintanance mode impact (#3858) 2023-05-25 08:28:05 +02:00
Mateusz Kwasniewski
5ac575389e
feat: maintenance mode disables scheduler (#3854) 2023-05-24 12:26:54 +02:00
Nuno Góis
ab4ff29407
fix: hide password login when it's disabled (#3851)
https://linear.app/unleash/issue/2-1085/bug-password-based-login-still-shows-on-the-login-page-even-if

Fixes a regression introduced with the changes related with #3633 where
we still show the password login even though it's disabled.

---------

Co-authored-by: Thomas Heartman <thomas@getunleash.io>
2023-05-24 09:39:24 +01:00
Nuno Góis
c0bcc50b28
fix: add confirmation to disable password login (#3829)
https://linear.app/unleash/issue/2-1071/prevent-users-from-disabling-password-authentication-when-there-are-no

Improves the behavior of disabling password based login by adding some
relevant information and a confirmation dialog with a warning. This felt
better than trying to disable the toggle, by still allowing the end
users to make the decision, except now it should be a properly informed
decision with confirmation.


![image](https://github.com/Unleash/unleash/assets/14320932/2ca754d8-cfa2-4fda-984d-0c34b89750f3)

- **Password based administrators**: Admin accounts that have a password
set;
- **Other administrators**: Other admin users that do not have a
password. May be SSO, but may also be users that did not set a password
yet;
- **Admin service accounts**: Service accounts that have the admin root
role. Depending on how you're using the SA this may not necessarily mean
locking yourself out of an admin account, especially if you secured its
token beforehand;
- **Admin API tokens**: Similar to the above. If you secured an admin
API token beforehand, you still have access to all features through the
API;

Each one of them link to the respective page inside Unleash (e.g. users
page, service accounts page, tokens page...);

If you try to disable and press "save", and only in that scenario, you
are presented with the following confirmation dialog:


![image](https://github.com/Unleash/unleash/assets/14320932/5ad6d105-ad47-4d31-a1df-04737aed4e00)
2023-05-23 15:56:34 +01:00
Mateusz Kwasniewski
1dba9d092b
fix: move application logic to service (#3846) 2023-05-23 16:41:52 +02:00
Mateusz Kwasniewski
840ca275cf
feat: disable bulk update env var (#3828) 2023-05-22 13:12:45 +00:00
Mateusz Kwasniewski
e34c9bc0bf
feat: disable bulk toggles flag (#3827) 2023-05-22 13:31:31 +02:00
David Leek
485dab87d4
docs: openapi schema specifications for Projects tag (#3571)
<!-- 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. -->

Improves the openapi schema specifications for the schemas belonging to
the "Projects" tag.
Expected error codes/http statues, descriptions, and example data

---------

Co-authored-by: Christopher Kolstad <chriswk@getunleash.ai>
Co-authored-by: Thomas Heartman <thomas@getunleash.ai>
2023-05-19 09:07:23 +02:00
Mateusz Kwasniewski
f9409fc0e6
feat: transactional bulk update (#3806) 2023-05-19 08:44:17 +02:00
Nuno Góis
4adc977ba0
fix: properly handle flag resolver variants (#3808)
Variants were not being properly handled in the `flag-resolver`: The
fact that the default value of the variant is not falsy made it so we
never asked the external flag resolver for the value.

This also moves the logic from `Variant | undefined` to `Variant` where
we use the `getDefaultVariant()` helper method to return us a [default
variant](55274e4953/src/variant.ts (L37-L42)).
2023-05-18 17:04:55 +01:00
Nuno Góis
db61a8a40c
feat: message banner (variants) (#3788)
-
https://linear.app/unleash/issue/2-546/fetch-the-payload-from-a-real-feature-flag
-
https://linear.app/unleash/issue/2-547/adapt-ui-to-use-the-feature-flag-information-were-fetching

Tackles the 2 tasks above. 

Adapts our `FlagResolver` logic to support variants, so we can use them
for our message banner project but also anything else in the future.
Also adapts MessageBanner to the new logic.

 - Add support for variants in `FlagResolver`;
 - Adapt `MessageBanner` to a variants flag;
 - Adds `sticky` support for the `MessageBanner`;
- Adds our first variants flag to `uiConfig` and `experimental`:
`messageBanner`;
- Adds a `variant-flag-schema` to make it easy to represent the variant
output that we specify in `uiConfig`;
- Adapts `experimental` to be able to represent default variants while
still maintaining type safety;
- Adds helpers to make it easy to use variants in our project, such as
`getVariantValue` and the `useVariant` hook;
 - Adapts and adds new tests in `flag-resolver.test.ts`;
 
### Notes

- ~~The `as PayloadType` assertions need
https://github.com/Unleash/unleash-client-node/pull/454 since it
includes https://github.com/Unleash/unleash-client-node/pull/452~~
(50ccf60893);
 - ~~Enterprise needs a PR that will follow soon~~;
 
 

![image](https://github.com/Unleash/unleash/assets/14320932/034ff64f-3020-4ed0-863b-ed1fd9190430)
2023-05-18 09:38:59 +01:00
Mateusz Kwasniewski
6b41cf03a0
feat: Basic bulk update implementation (#3794) 2023-05-17 12:20:32 +02:00
Mateusz Kwasniewski
45505d6996
feat: create stubs for bulk toggle (#3792) 2023-05-17 10:21:08 +02:00
Simon Hornby
efbec719de
fix: block adding a root role to a group with a project role (#3775) 2023-05-16 12:11:32 +02:00
Mateusz Kwasniewski
d37bb6a790
feat: base path support for openapi (#3780) 2023-05-16 12:01:47 +02:00
Christopher Kolstad
e5e4d52219
fix: anonymise PII fields in user access if flag is set (#3773)
### What
In the demo when listing possible users to grant access to your project,
we inadvertently expose emails when listing users you can grant access
to. This PR anonymises the access list on the way out.
2023-05-15 14:12:03 +02:00
Gastón Fournier
024c6c1990
chore: add additional methods we want exposed (#3771)
## About the changes
These methods are being used externally as part of our enterprise
package
2023-05-15 10:23:28 +00:00
Thomas Heartman
741135a171
fix: add missing options parameter back in (#3770)
This PR adds the missing serialization of the AuthenticationRequired
response back in. It was mistakenly removed in #3633.

This PR also adds another test to verify that it the options property is
present.
2023-05-15 07:19:55 +00:00
Ivar Conradi Østhus
6c5df9f2c7
feat: improve frontend config freshness to < 1s (#3749)
This PR reuses the revision Id information from the "optimal 304 for
server SDKs" to improve the freshness of the frontend API config data.

In addition it allows us to reduce the polling (and eventually remove it
when we are confident).

---------

Co-authored-by: Gastón Fournier <gaston@getunleash.io>
2023-05-12 17:52:11 +00:00
David Leek
534e1f1378
chore: add another migration that remigrates the proper way (#3719)
## 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. -->

Adds a migration that renames `token_name` back to `username`, then adds
a new optional column named `token_name`

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

I've added fallbacks for resolving username/tokenname on insert and on
making rows from results.
But this adds another column renaming, which is worth discussing
properly
2023-05-11 15:33:04 +02:00
Thomas Heartman
9943179393
Clean up old errors (#3633)
This PR attempts to improve the error handling introduced in #3607.

## About the changes

## **tl;dr:**
- Make `UnleashError` constructor protected
- Make all custom errors inherit from `UnleashError`.
- Add tests to ensure that all special error cases include their
relevant data
- Remove `PasswordMismatchError` and `BadRequestError`. These don't
exist.
- Add a few new error types: `ContentTypeError`, `NotImplementedError`,
`UnauthorizedError`
- Remove the `...rest` parameter from error constructor
- Add an unexported `GenericUnleashError` class
- Move OpenAPI conversion function to `BadDataError` clas
- Remove explicit `Error.captureStackTrace`. This is done automatically.
- Extract `getPropFromString` function and add tests

### **In a more verbose fashion**

The main thing is that all our internal errors now inherit
from`UnleashError`. This allows us to simplify the `UnleashError`
constructor and error handling in general while still giving us the
extra benefits we added to that class. However, it _does_ also mean that
I've had to update **all** existing error classes.

The constructor for `UnleashError` is now protected and all places that
called that constructor directly have been updated. Because the base
error isn't available anymore, I've added three new errors to cover use
cases that we didn't already have covered: `NotImplementedError`,
`UnauthorizedError`, `ContentTypeError`. This is to stay consistent in
how we report errors to the user.

There is also an internal class, `GenericUnleashError` that inherits
from the base error. This class is only used in conversions for cases
where we don't know what the error is. It is not exported.

In making all the errors inherit, I've also removed the `...rest`
parameter from the `UnleashError` constructor. We don't need this
anymore.

Following on from the fixes with missing properties in #3638, I have
added tests for all errors that contain extra data.

Some of the error names that were originally used when creating the list
don't exist in the backend. `BadRequestError` and
`PasswordMismatchError` have been removed.

The `BadDataError` class now contains the conversion code for OpenAPI
validation errors. In doing so, I extracted and tested the
`getPropFromString` function.

### Main files

Due to the nature of the changes, there's a lot of files to look at. So
to make it easier to know where to turn your attention:

The changes in `api-error.ts` contain the main changes: protected
constructor, removal of OpenAPI conversion (moved into `BadDataError`.

`api-error.test.ts` contains tests to make sure that errors work as
expected.

Aside from `get-prop-from-string.ts` and the tests, everything else is
just the required updates to go through with the changes.

## Discussion points

I've gone for inheritance of the Error type over composition. This is in
large part because throwing actual Error instances instead of just
objects is preferable (because they collect stack traces, for instance).
However, it's quite possible that we could solve the same thing in a
more elegant fashion using composition.

## For later / suggestions for further improvements

The `api-error` files still contain a lot of code. I think it might be
beneficial to break each Error into a separate folder that includes the
error, its tests, and its schema (if required). It would help decouple
it a bit.

We don't currently expose the schema anywhere, so it's not available in
the openapi spec. We should look at exposing it too.

Finally, it would be good to go through each individual error message
and update each one to be as helpful as possible.
2023-05-11 11:10:57 +02:00
David Leek
546f9953a7
docs: openapi schema for PATs (#3605)
<!-- 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. -->

OpenAPI schema updates for Personal Access Tokens, http statuses,
property types and examples, return types

---------

Co-authored-by: Nuno Góis <github@nunogois.com>
Co-authored-by: mergify[bot] <37929162+mergify[bot]@users.noreply.github.com>
Co-authored-by: Thomas Heartman <thomas@getunleash.ai>
2023-05-11 09:11:17 +02:00
Christopher Kolstad
eaacb979d6
fix: Removed CR on variants flag (it's GA) (#3738)
This PR removes the usage of crOnVariants flag, but keeps the behaviour,
so CR are now enabled on variants.

---------

Co-authored-by: Nuno Góis <github@nunogois.com>
2023-05-10 13:46:41 +00:00
Christopher Kolstad
af3944bd75
fix: log missing user at warn level (#3735)
When using PATs if the user that the PAT is for has been removed, we
currently log the missing user at ERROR level. Since this is not
something our SREs can fix, this PR downgrades the NotFoundError to
WARN, instead of ERROR.
2023-05-10 13:31:42 +02:00
Nuno Góis
72eba37cec
test: add anonymise unit tests (#3722)
Adds unit tests to `anonymise` functions. 

See:
https://github.com/Unleash/unleash/pull/3683#pullrequestreview-1418223563
2023-05-09 14:20:39 +01:00
andreas-unleash
5229c44dcb
fix: bypass change requests when unprotected deleting (#3720)
<!-- 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-05-09 14:18:21 +03:00
andreas-unleash
b132cce986
fix: project api token type to lowercase (#3717)
<!-- 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-05-09 09:22:21 +00:00
Nuno Góis
b013d4286c
fix: log project access events (#3683)
https://linear.app/unleash/issue/2-992/register-event-when-granting-access-to-a-project

 - Correctly registers a new `project-access-added` event;
- Adds an anonymization method that supports anonymizing objects,
recursively searching for keys to anonymize;
- Fixes the event label used by `ProjectUserUpdateRoleEvent` to be
`PROJECT_USER_ROLE_CHANGED`;


![image](https://user-images.githubusercontent.com/14320932/236216227-bf6e5dff-f509-48a4-ba7c-9f37e23e87c0.png)
2023-05-09 11:13:38 +02:00
Simon Hornby
3ed4aeba5c
chore: expand default segment limits to 1000 (#3710)
This expands the segment limits to 1000, this should have no impact on
OSS since this feature isn't exposed. This is overridden to 250 in
hosted `pro` instances and 1000 in hosted `enterprise` customers. This
only affects self hosted enterprise instances
2023-05-08 14:44:48 +02:00
andreas-unleash
3c8b766ea6
fix: Add default value for shouldActivateDisabledStrategies (#3711)
<!-- 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-05-08 14:56:42 +03:00
andreas-unleash
83bb9b1656
Feat: enable toggle dialog (#3686)
<!-- 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! ❤️ -->
- Creates a dialog when the feature has ONLY disabled strategies and the
environment in turned on
- Adds functionality to either `enable` the strategies or add the
default one (if a project specific default strategy is set, uses it)
## 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? -->



Uploading Screen Recording 2023-05-05 at 17.40.48.mov…



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-05-08 11:42:26 +03:00
andreas-unleash
a8936a13c3
Feat: default strategy UI (#3682)
<!-- 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! ❤️ -->
- Removed `strategyTitle` and `strategyDisable` flags. Unified under
`strategyImprovements` flag
- Implements the default strategy UI
- Bug fixes

## 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-875](https://linear.app/unleash/issue/1-875/default-strategy-frontend)

<!-- (For internal contributors): Does it relate to an issue on public
roadmap? -->
<!--
Relates to [roadmap](https://github.com/orgs/Unleash/projects/10) item:
#
-->
![Screenshot 2023-05-04 at 11 21
05](https://user-images.githubusercontent.com/104830839/236149232-84601829-1327-42af-9527-5cc15196517a.png)

### 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-05-05 14:32:44 +03:00
Jaanus Sellin
50fe3ebcaf
feat: metrics for variants (#3685) 2023-05-05 11:10:54 +03:00
Gastón Fournier
149bc8aab2
chore: remove optimal 304 flag (#3665)
## About the changes
This PR removes the optimal304 flag after being tested in production.
We're keeping the existing configuration that allows users to disable
cache mainly because it's useful for testing.
2023-05-05 09:18:04 +02:00
Mateusz Kwasniewski
108e15940e
fix: don't create duplicate tags on import (#3688) 2023-05-04 22:19:00 +02:00
David Leek
f35d9390c1
chore: deprecate username on api-tokens (#3616)
<!-- 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. -->

This deprecates the `username` properties on api-token schemas, and adds
a `tokenName` property.
DB field `username` has been renamed to `token_name`, migration added
for the rename.
Both `username` and `tokenName` can be used when consuming the service,
but only one of them.

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

There's a couple of things I'd like to get opinions on and discuss:
- Frontend still uses the deprecated `username` property
- ApiTokenSchema is used both for input and output of `Create`
controller endpoints and should be split out into separate schemas. I'll
set up a task for this

---------

Co-authored-by: Thomas Heartman <thomas@getunleash.ai>
Co-authored-by: mergify[bot] <37929162+mergify[bot]@users.noreply.github.com>
2023-05-04 09:56:00 +02:00
Nuno Góis
fb999e6a74
fix: anonymize email in event payload (#3672)
Context:
https://unleash-internal.slack.com/archives/C048ELND3QD/p1683097636083299

We should also anonymize email fields in `data` and `preData` of event
objects when `anonymiseEventLog` is enabled.


![image](https://user-images.githubusercontent.com/14320932/235862643-b59a3f8d-9bc6-4b22-816b-9bc7a0577bfc.png)
2023-05-03 09:46:33 +00:00
andreas-unleash
d45f81ab02
fix: set feature.enabled to false when all strategies are deactivated (#3655)
<!-- 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! ❤️ -->
set feature.enabled to false when all strategies are deactivated
## 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>
Co-authored-by: Prabodh Meshram <prabodh.meshram7@gmail.com>
2023-05-02 21:33:14 +03:00
Thomas Heartman
80cf27476b
openapi: enable allErrors and update snapshots (#3622)
## What

This PR changes our AJV configuration to return all errors it finds with
a schema instead of stopping at the first one.

Because of this, a number of the snapshot tests that we have must be
updated.

## Why

DX! As someone using an API: if I send a faulty request, I'd rather have
the API tell me about the five things that are wrong than for me to
learn about one thing, send a new request, learn about another thing,
send a new request, .... etc.

Co-authored-by: mergify[bot] <37929162+mergify[bot]@users.noreply.github.com>
2023-04-28 12:56:00 +00:00
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
Jaanus Sellin
2a6cfc434f
fix: fix bulk removal of tags (#3651) 2023-04-28 14:49:34 +03:00
Mateusz Kwasniewski
c8bce08e94
feat: remove project overview flag (#3648) 2023-04-28 12:25:59 +02: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
Jaanus Sellin
383aa3dde4
feat: remove bulk operations flag (#3643) 2023-04-28 11:18:03 +03:00
Mateusz Kwasniewski
116db8f6d1
feat: promote toggles script (#3639) 2023-04-28 09:08:12 +02: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
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
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
Thomas Heartman
0613ee0bd9
fix: add truth checks to a number of jest tests. (#3627) 2023-04-26 14:24:09 +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
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
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
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
Jaanus Sellin
f9686a3a33
feat: add plausible as connect src (#3619) 2023-04-25 14:24:54 +03:00
Jaanus Sellin
28f61e05ff
feat: fix csp headers for feedback form (#3617)
Fix feedback form failing due to missing csp headers
2023-04-25 13:40:55 +03:00
andreas-unleash
e70be0739b
fix: BE protection for empty stickiness (#3615)
Add 'default' when creating or throw error when updating a
flexibleRollout strategy with empty stickiness
<!-- 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-25 12:57:16 +03:00
Mateusz Kwasniewski
545e231cae
feat: enable dark mode for all (#3614) 2023-04-25 10:13:06 +02:00
Nuno Góis
2129736ca6
chore: make login history GA (remove flag) (#3604)
https://linear.app/unleash/issue/2-956/remove-loginhistory-feature-flag

Promotes [login
history](https://docs.getunleash.io/reference/login-history) to GA by
removing the `loginHistory` feature flag.
2023-04-24 12:37:13 +01:00
andreas-unleash
193c12acd8
chore: docs for public signup token tag (#3486)
<!-- 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 #
[1-863](https://linear.app/unleash/issue/1-836/update-endpoints-for-tag-public-signup-tokens)

<!-- (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>
Co-authored-by: Thomas Heartman <thomas@getunleash.ai>
2023-04-21 11:26:54 +00:00
Gastón Fournier
4dd4d43cce
chore: remove deprecated strategies and allow deprecate default (#3575)
## About the changes
Improvements around strategies to steer users toward using [strategy
constraints](https://docs.getunleash.io/reference/strategy-constraints)
instead of [custom
strategies](https://docs.getunleash.io/reference/custom-activation-strategies)


Related to #1265 

Important changes:
1.[ Ability to deprecate default
strategy](https://github.com/Unleash/unleash/pull/3575/files#diff-3b49e566565b01580ff7a15f662d2cb824547fdfb3935d0a0baa7fae326d28d6L232-L235)
2. [Remove strategies that were deprecated in v4 only if they're not
used](https://github.com/Unleash/unleash/pull/3575/files#diff-a04de7adf327c48d54b030bed70d9b1d62ff14df3efc668eb6897a210124ebe0R7-R10)
3. [Fresh Unleash installations will not include deprecated strategies
from
v4](https://github.com/Unleash/unleash/pull/3575/files#diff-46265b0d51725a5acbf251589b98a8970e45d3a1c6f3d7ea77bdcc3714e672d8L31-L78)
4. [Deprecate userWithId
strategy](https://github.com/Unleash/unleash/pull/3575/files#diff-a04de7adf327c48d54b030bed70d9b1d62ff14df3efc668eb6897a210124ebe0R13)
(note: if in use it will continue to work, it'll be not listed when
selecting strategies for a feature toggle).
5. [Switch the order of strategies to make gradual rollout first and
change the comment to suggest using gradual rollout instead of other
existing
strategies](https://github.com/Unleash/unleash/pull/3575/files#diff-a04de7adf327c48d54b030bed70d9b1d62ff14df3efc668eb6897a210124ebe0R16-R18)
2023-04-21 11:42:36 +02:00
andreas-unleash
097dd8ae56
Feat/enable disable strategies (#3566)
<!-- 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 enabled field to feature strategies
Filter out disabled strategies when returning/evaluating

## 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-865](https://linear.app/unleash/issue/1-865/allow-for-enablingdisabling-strategies-in-place-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-21 12:09:07 +03:00
Gastón Fournier
ab4a6f5c92
chore: GA project specific segments (#3583)
## About the changes
General availability of project-specific segments 

Now new permissions can be assigned to non-admin users to allow them to
create segments specifically bounded to a project (note that unique
naming restriction applies across projects, this limitation can be
lifted later).

![image](https://user-images.githubusercontent.com/455064/233579161-40ab25c5-a306-4fbc-82e5-8d09b3cb6a5f.png)

This enables a section in the project configuration to add
project-specific segments

![image](https://user-images.githubusercontent.com/455064/233578924-7056c626-ff1f-4dad-b00c-7fbd851158a6.png)
2023-04-21 10:25:40 +02:00
Gastón Fournier
ca01a79f71
chore: drop event hook (#3565)
## About the changes
Ref:
https://docs.getunleash.io/reference/deploy/configuring-unleash#further-customization
> **eventHook** (`function(event, data)`) - (_deprecated in Unleash 4.3_
in favor of the [Webhook addon](../addons/webhook.md)) If provided, this
function will be invoked whenever a feature is mutated. The possible
values for `event` are `'feature-created'`, `'feature-archived'` and
`'feature-revived'`. The `data` argument contains information about the
mutation. Its fields are `type` (string) - the event type (same as
`event`); `createdBy` (string) - the user who performed the mutation;
`data` - the contents of the change. The contents in `data` differs
based on the event type; For `'feature-archived'` and
`'feature-revived'`, the only field will be `name` - the name of the
feature. For `'feature-created'` the data follows a schema defined in
the code
[here](7b7f0b84e8/src/lib/schema/feature-schema.ts (L77)).
See an [api here](/reference/api/legacy/unleash/admin/events).


Related to: https://github.com/Unleash/unleash/issues/1265
2023-04-21 09:44:18 +02:00
Simon Hornby
3b42e866ec
feat: root roles from groups (#3559)
feat: adds a way to specify a root role on a group, which will cause any user entering into that group to take on the permissions of that root role

Co-authored-by: Nuno Góis <github@nunogois.com>
2023-04-20 12:29:30 +02:00
Gastón Fournier
551c00b6b2
fix: compilation issues from event-store (#3568)
## About the changes
Reduce compilation errors on event-store
2023-04-20 11:37:38 +02:00
Tymoteusz Czech
169b2bd0c5
Strategy title frontend (#3556)
Ability to add a title to a strategy
2023-04-19 17:27:23 +00:00
Christopher Kolstad
4f7fd46623
fix: return 404 when gettings tags for a non existing feature (#3560)
From the discussion here
https://github.com/Unleash/unleash/pull/3496#discussion_r1163745860

This PR checks the existence of the feature before trying to get tags
for the feature. Doing so by stealing the exists method from the feature
store, since that's what we need to know exists, and avoiding having the
feature store as a dependency to the featureTagStore seemed reasonable.
2023-04-19 14:10:13 +02:00
Gastón Fournier
008d9b8bb6
feat: deprecate state api (#3551)
## About the changes
This deprecates state API in favor of the new batch import/export
2023-04-18 18:34:12 +02:00
Thomas Heartman
34204c3565
chore: remove uses of type errors from user-facing code (#3553)
BREAKING CHANGE: This changes the `name` property of a small number of error responses that we return. The property would have been `TypeError`, but is now `ValidationError` instead. It's a grey area, but I'd rather be strict.

---

This change removes uses of the `TypeError` type from user-facing code.
Type errors are used by typescript when you provide it the wrong type.
This is a valid concern. However, in the API, they're usually a signal
that **we've** done something wrong rather than the user having done
something wrong. As such, it makes more sense to return them as
validation errors or bad request errors.

## Breaking changes

Note that because of the way we handle errors, some of these changes
will be made visible to the end user, but only in the response body.

```ts
{ "name": "TypeError", "message": "Something is wrong", "isJoi": true }
```

will become

```ts
{ "name": "ValidationError", "message": "Something is wrong", "isJoi": true }
```

Technically, this could be considered a breaking change. However, as
we're gearing up for v5, this might be a good time to merge that?

## A return to 500

This PR also makes TypeErrors a 500-type error again because they should
never be caused by invalid data provided by the user
2023-04-18 13:42:07 +02:00
Thomas Heartman
e11fae56e9
OpenAPI: addon operations (#3421)
This PR updates the OpenAPI schemas for all the operations tagged with
"addons". In doing so, I also uncovered a few bugs and inconsistencies.
These have also been fixed.

## Changes

I've added inline comments to the changed files to call out anything
that I think is worth clarifying specifically. As an overall
description, this PR does the following:

Splits `addon-schema` into `addon-schema` and
`addon-create-update-schema`. The former is used when describing addons
that exist within Unleash and contain IDs and `created_at` timestamps.
The latter is used when creating or updating addons.

Adds examples and descriptions to all relevant schemas (and their
dependencies).

Updates addons operations descriptions and response codes (including the
recently introduced 413 and 415).

Fixes a bug where the server would crash if it didn't recognize the
addon provider (test added).

Fixes a bug where updating an addon wouldn't return anything, even if
the API said that it would. (test added)

Resolves some inconsistencies in handling of addon description. (tests
added)

### Addon descriptions

when creating addons, descriptions are optional. The original
`addonSchema` said they could be `null | string | undefined`. This
caused some inconsistencies in return values. Sometimes they were
returned, other times not. I've made it so that `descriptions` are now
always returned from the API. If it's not defined or if it's set to
`null`, the API will return `description: null`.

### `IAddonDto`

`IAddonDto`, the type we used internally to model the incoming addons
(for create and update) says that `description` is required. This hasn't
been true at least since we introduced OpenAPI schemas. As such, the
update and insert methods that the service uses were incompatible with
the **actual** data that we require.

I've changed the type to reflect reality for now. Assuming the tests
pass, this **should** all be good, but I'd like the reviewer(s) to give
this a think too.

---------

Co-authored-by: Christopher Kolstad <chriswk@getunleash.ai>
2023-04-18 10:50:34 +00:00
Gastón Fournier
c97294aee4
Fix openapi tests (#3549)
## About the changes
Update tests due to fixes introduced in
2da279b7fb

This PR removes the fixes from the exceptions' list
2023-04-18 08:17:23 +00:00
andreas-unleash
2da279b7fb
feat: add title to strategy (#3510)
<!-- 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 title column to strategies, feature_strategies and features_view in
the db
Updates model/schemas
## 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-855](https://linear.app/unleash/issue/1-855/allow-for-title-on-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-18 08:59:02 +02:00
Gastón Fournier
5940a81158
docs: improve open api (#3535)
## About the changes
Amends based on https://github.com/Unleash/unleash/pull/3519
2023-04-18 08:50:36 +02:00
Mateusz Kwasniewski
5fa13aba0e
feat: remove project overview flags (#3532) 2023-04-17 11:21:52 +02:00
Gastón Fournier
4f78db3be9
fix: segments schemas (#3525)
## About the changes
Remove segment schemas from exceptions

---------

Co-authored-by: GitHub Actions Bot <>
2023-04-17 10:51:48 +02:00
Gastón Fournier
d9b6357281
Fix main after OpenAPI fixes (#3530)
## About the changes
After fixing some OpenAPI descriptions:
6cc51b7ba0
this test needs to be updated
2023-04-17 10:34:29 +02:00
Gastón Fournier
ea9bf7f447
chore: add linter rules for regexp (#3500)
## About the changes
Add linter rules for regexp security vulnerabilities

Commit 1c5d54c76e [fails due to
regexp/no-super-linear-backtracking](https://github.com/Unleash/unleash/actions/runs/4668430535/jobs/8265506170#step:5:37)
as reported here:
https://github.com/Unleash/unleash/security/code-scanning/1


[0127d1a](0127d1a746)
fixes the issues and warnings by running `yarn lint --fix`
2023-04-17 07:11:22 +00:00
Christopher Kolstad
6cc51b7ba0
docs: Added docs for edge endpoints (#3501)
Adding documentation for the edge endpoints. Also separating request and
response schema for our validate endpoint to make clear that we expect a
list of strings as input, but yield tokens as output.

---------

Co-authored-by: Gastón Fournier <gaston@getunleash.io>
Co-authored-by: Thomas Heartman <thomas@getunleash.ai>
2023-04-14 15:39:39 +02:00
Gastón Fournier
9105f31e81
fix: test in main (#3526)
## About the changes
Due to some merge conflict some open API specs marked as exceptions are
no longer exceptions
2023-04-14 12:30:11 +00:00
Gastón Fournier
ff99ffc27c
chore: rule for description on properties (#3523)
## About the changes
This rule defines that all properties should have a description

We also considered enforcing an example but we noticed that in some
cases that's not needed.
2023-04-14 13:38:58 +02:00
Gastón Fournier
d4c24c9520
chore: amend open api tags descriptions and examples (#3519)
## About the changes
Adds descriptions and examples to tag schemas
2023-04-14 12:26:19 +02:00
Gastón Fournier
19982ecbc7
chore: test requirements for openapi (#3511)
## About the changes
This enables us to validate the shape of our OpenAPI schemas by defining
specific json-schema rules that will be evaluated against all our open
API schemas.

Because we know there are things we need to improve, we've added a list
of `knownExceptions`. When fixing some of the known exceptions the tests
will force us to remove the exception from the list, that way
contributing to reducing the number of violations to our own rules.

Co-authored-by: Mateusz Kwasniewski <kwasniewski.mateusz@gmail.com>
Co-authored-by: Thomas Heartman <thomas@getunleash.io>
2023-04-14 10:37:17 +02:00
Mateusz Kwasniewski
51e871da96
fix: 4 param error handler (#3520) 2023-04-14 08:59:27 +02:00
Nuno Góis
d2da6de7d5
feat: adds demo feature flag (#3514)
https://linear.app/unleash/issue/2-912/create-demo-feature-flag

Adds `demo` as a feature flag that controls the new interactive demo
feature.
2023-04-13 12:06:00 +01:00
andreas-unleash
60a2c1a996
chore: Backport 4.22.3 (#3508)
<!-- 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! ❤️ -->
Backports stickiness fixes 
## 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>
Co-authored-by: Gastón Fournier <gaston@getunleash.io>
Co-authored-by: GitHub Actions Bot <>
Co-authored-by: Mateusz Kwasniewski <kwasniewski.mateusz@gmail.com>
2023-04-12 16:22:13 +03:00
Mateusz Kwasniewski
4c30a5dcac
chore: remove unused flags (#3506) 2023-04-12 09:57:43 +00:00
Gastón Fournier
37beaa611f
chore: Improve openapi documentation for tags (#3496)
## About the changes
1. Create tag should not throw a 500 when bad data is provided
2. Added summary, description and examples to open API endpoints

---------

Co-authored-by: Nuno Góis <github@nunogois.com>
2023-04-12 09:34:32 +00:00
Gastón Fournier
c1a1a0fdeb
docs: open api examples for segment schemas (#3503)
## About the changes
Add additional documentation for segments

---------

Co-authored-by: Nuno Góis <github@nunogois.com>
2023-04-12 09:29:51 +00:00
Mateusz Kwasniewski
84bf60ca78
feat: Catch all error handler (#3499) 2023-04-12 08:05:34 +02:00
Gastón Fournier
5ff883bc69
fix: security vulnerability (#3497)
This was an oversight of https://github.com/Unleash/unleash/pull/3402
2023-04-11 16:13:59 +02:00
Mateusz Kwasniewski
d9f22f4349
feat: Maintenance openapi (#3478) 2023-04-10 09:55:29 +02:00
Mateusz Kwasniewski
f1133556bd
refactor: switching to new stats calculations (#3477) 2023-04-10 09:50:39 +02:00
Mateusz Kwasniewski
8d61332543
refactor: Improved lead time calculation (#3475) 2023-04-07 13:31:27 +02:00
Tymoteusz Czech
8f278cb726
Fix: feature schema (#3456) 2023-04-07 09:16:00 +00:00
Mateusz Kwasniewski
126d2d2e45
feat: save memory on reading stats (#3472) 2023-04-06 15:34:08 +02:00
Jaanus Sellin
14a2ca700c
feat: rate limit user creation (#3468) 2023-04-06 13:45:54 +02:00
Jaanus Sellin
33487d11b9
feat: authorization middleware (#3464) 2023-04-06 11:46:54 +02:00
Jaanus Sellin
80bea14d42
feat: changing password will expire reset password tokens (#3451) 2023-04-05 12:39:52 +03:00
Gastón Fournier
0e37e68424
feat: add PAT kill switch (#3454)
## Add the ability to disable Personal Access Tokens (PAT) admin API

This PR disables PAT admin endpoints so it's not possible to create or
get PATs the kill switch is enabled, the UI is hidden but the existing
PATs will continue to work if they were created before. The delete
endpoint still works allowing an admin to delete old PATs

By default the kill switch is disabled (i.e. PAT is enabled by default)
2023-04-05 10:20:50 +02:00
Christopher Kolstad
512efe0809
docs: Flesh out openapi for tag: Environments (#3440)
### What
This fleshes out the documentation for actions tagged with Environments.

Co-authored-by: Thomas Heartman <thomas@getunleash.ai>
2023-04-04 15:45:34 +02:00
andreas-unleash
3a84dfde08
fix: bug (#3449)
<!-- 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! ❤️ -->
Remove enum for defaultStickiness from joi schema
## 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-04 15:52:45 +03:00
Mateusz Kwasniewski
c16fde5ab4
test: increase timer values in scheduler integration test (#3448) 2023-04-04 14:15:45 +02:00
Mateusz Kwasniewski
8654c9ea42
feat: postgres lock (#3443) 2023-04-04 13:28:17 +02:00
Gastón Fournier
2bfbe3cd79
fix: concurrency issue when running multiple requests (#3442)
## About the changes

Fix issue when running multiple calls to the /frontend endpoint concurrently, which ends up creating many instances of unleash SDK client.
2023-04-04 09:32:35 +02:00
Gastón Fournier
36f1125c25
fix: input used to read file should be sanitized (#3402)
## About the changes
Following the recommendation to fix
https://github.com/Unleash/unleash/security/code-scanning/2 and
https://github.com/Unleash/unleash/security/code-scanning/3

The endpoint seems to be used for developing purposes only (to preview
an email under development) but it's available in every Unleash
installation and can potentially be exploited.
2023-04-03 14:17:44 +02:00
Nuno Góis
07e8e5826c
refactor: revert adding apiPagination feature flag (#3433)
Reverts https://github.com/Unleash/unleash/pull/3417 - If we're not
going forward with this project at this stage, we should clean up after
ourselves and remove the unused flag that we added.
2023-03-31 13:20:18 +02:00
Nuno Góis
fbb1280b0e
fix: show profile projects correctly (#3422)
Profile projects were not showing correctly in most cases. This fixes
the query to only take into consider whether you have access to the
project (either directly or through a group).

![image](https://user-images.githubusercontent.com/14320932/228598175-874f0daa-8d33-49a8-b6f8-072942876138.png)
2023-03-30 07:37:42 +00:00
andreas-unleash
87c1407923
chore: remove showProjectApiAccess flag (#3406)
<!-- 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! ❤️ -->

Remove `showProjectApiAccess` flag

## 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-03-30 10:22:45 +03:00
Nuno Góis
2a4ef56935
feat: add API pagination feature flag (#3417)
https://linear.app/unleash/issue/2-826/add-pagination-feature-flag

Adds `apiPagination` feature flag in order to start
https://linear.app/unleash/project/[med][m][none]-api-filter-and-pagination-support-29ef4909dd2e/2
2023-03-29 09:01:57 +01:00
andreas-unleash
9b6f5cd198
fix: make api tokens ui consistent and remove check for deprecated envs. (#3410)
<!-- 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! ❤️ -->

This PR removes the check for deprecated environments when validating
api token environment.

Unifies global and project level tokens allow selection of deprecated
environments when creating an api token

Adds 'deprecated' to the EnvironmentSelector when appropriate

## 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-03-29 10:33:14 +03:00
Jaanus Sellin
99bcd7ca5c
feat: add import export flag (#3411) 2023-03-29 09:19:33 +03:00
andreas-unleash
0d68febdf7
Fix: make stickiness accept any string (#3408)
<!-- 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! ❤️ -->
Changes the schema and api to accept any string for defaultStickiness
## 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-03-28 16:42:16 +03:00
Mateusz Kwasniewski
3b311f74c0
feat: stop change project on change request enabled (#3391) 2023-03-28 11:28:22 +02:00
Fredrik Strand Oseberg
a98bfb2229
fix: remove notification feature flag from oss (#3390)
Removes the notifications feature flag
2023-03-27 16:08:27 +02: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
Fredrik Strand Oseberg
354e54a356
fix: count events instead of loading them in memory (#3382)
Refactor project events to use count instead of loading the events in
memory
2023-03-27 11:24:01 +02:00
Ivar Conradi Østhus
b5a31dabc4
fix: use correct casing fro ETag header (#3387) 2023-03-27 08:32:49 +00:00
Christopher Kolstad
49fbf4a635
task: enclose ETag in double quotes. (#3385)
According to the
[RFC](https://www.rfc-editor.org/rfc/rfc7232#section-2.3) Etags should
be enclosed in double quotes. This PR makes sure we do actually wrap it
in double quotes
2023-03-24 16:11:42 +01:00
Mateusz Kwasniewski
ab913228ca
refactor: read model for change request access checking (#3380) 2023-03-24 14:31:43 +01:00
Gastón Fournier
3f29fa5ec8
refactor: fix compilation issues in features service (#3323)
## About the changes
This PR fixes a bunch of null check errors:
https://github.com/Unleash/unleash/actions/runs/4509279284/jobs/7938853559#step:5:39
2023-03-24 10:43:38 +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