1
0
mirror of https://github.com/Unleash/unleash.git synced 2025-10-27 11:02:16 +01:00
Commit Graph

3065 Commits

Author SHA1 Message Date
Gastón Fournier
fab5dc8725
fix: Information exposure through a stack trace (#10737)
Fix for
[https://github.com/Unleash/unleash/security/code-scanning/81](https://github.com/Unleash/unleash/security/code-scanning/81)

To prevent information exposure through stack traces, ensure that the
HTTP response sent to clients contains only sanitized, generic error
information, such as a status code and a simple message. Internal
details (including stack traces, error types, or internal error codes)
should not be sent to the client. These can be safely logged on the
server for debugging.

**The fix:**  
- Do not return the entire `finalError` object as JSON to the client, as
it may include fields like `stack` or `internalMessage`.
- Instead, return only a subset of fields that are safe to expose to the
user, in this case just `message` .
- Log the full error and any debugging details using the server-side
logger **as currently done**.


---
_Suggested fixes powered by Copilot Autofix. Review carefully before
merging._

---------

Co-authored-by: Copilot Autofix powered by AI <62310815+github-advanced-security[bot]@users.noreply.github.com>
2025-10-07 16:41:40 +02:00
Gastón Fournier
8f2cf5386d
fix: flaky test when updated_at matches the time of query (#10752) 2025-10-07 16:03:57 +02:00
Gastón Fournier
6a63e27ebd
fix: get users total right at startup (#10750)
# Summary
Add optional lazy collection with TTL to our createGauge wrapper,
allowing a gauge to fetch its value on scrape and cache it for a
configurable duration. This lets us register a collect function directly
at gauge declaration without changing existing call sites or behavior.

We're experimenting with this, reason why we're only applying the
solution to `users_total` and will evaluate afterwards.

# Problem
- Some gauges should be computed on scrape (e.g., expensive or external
lookups) instead of being pushed continuously.
- Our current `createGauge` helper doesn’t make it easy to attach a
`collect` with caching. Each caller has to reimplement timing, caching,
and error handling.
- This leads to repeated costly work, inconsistent handling of unknown
values, and boilerplate.
# What changed
- `createGauge` now accepts two optional options in addition to the
usual prom-client options:
    - `fetchValue?: () => Promise<number | null>`
    - `ttlMs?: number`
- When `fetchValue` is provided:
    - We install a `collect` that fetches on scrape.
- Successful values are cached for `ttlMs` milliseconds (if `ttlMs` >
0).
    - If `ttlMs` is 0 or omitted, we fetch on every scrape.
- If `fetchValue` returns null or throws, we set `NaN` (indicates
`"unknown"`).

# Behavior details
## Caching:
- A value is “fresh” when successfully fetched within `ttlMs`.
- Only numeric successes are cached. null and errors are not cached;
we’ll refetch on the next scrape.
## Unknown values:
- null or thrown errors set the gauge to `NaN` so Prometheus won’t treat
it as zero.
## Compatibility:
- Backward compatible. Existing uses of `createGauge` are unchanged.
If a user-supplied `collect` exists, it still runs after the TTL logic
(can overwrite the value by design).
- API remains the same for the returned wrapper: `{ gauge, labels,
reset, set }`.
2025-10-07 14:22:33 +02:00
Mateusz Kwasniewski
5e2d95e0be
refactor: move release plan schemas to OSS (#10748) 2025-10-07 12:28:28 +02:00
Gastón Fournier
bade23974e
feat: allow test operation for patch (#10736)
## About the changes
This would allow users to add test statements to protect from concurrent
modifications. From
https://github.com/orgs/Unleash/discussions/10707#discussioncomment-14602784

E.g.
If you had this feature flag configuration
```
{
  "name": "flexibleRollout",
  "constraints": [
    {
      "contextName": "a",
      "operator": "IN",
      "values": [
        "100", "200", "300", "400", "500"
      ],
      "caseInsensitive": false,
      "inverted": false
    }
  ],
  "parameters": {
    "rollout": "100",
    "stickiness": "default",
    "groupId": "api-access"
  },
  "variants": [],
  "segments": [
    122
  ],
  "disabled": false
}
```

And you'd like to remove the value 300 from the constraints, you'd have
to first get the current values and then PATCH the strategy with the
following body:
```
[{ "op": "remove", "path": "/constraints/0/values/2" }]
```

This could fail in case of concurrent modifications (e.g. if someone
removed the value "100", then the index to remove "300" will no longer
be 2).

With the test operation, you'd be able to add a protection mechanism to
validate that the value at index 2 is still 300:
```
[
    { "op": "test", "path": "/constraints/0/values/2", "value": "300" },
    { "op": "remove", "path": "/constraints/0/values/2" }
]
```
If the test fails, the remove operation will not be applied.

I've tested this locally and works as expected:
1. If the value is still 300, it will remove it
2. The operation will fail if the value is no longer 300 because of
another change.
2025-10-06 16:52:10 +02:00
Mateusz Kwasniewski
c3491abf4b
feat: milestone progressions migration (#10738) 2025-10-06 13:47:02 +02:00
Gastón Fournier
b1f4ebd5eb
chore: return user id alongside max updated_at (#10732)
This is for internal use
2025-10-06 11:43:40 +02:00
David Leek
c39b4cd1b0
feat: add a suggestion banner at the bottom of empty feature-environments (#10725) 2025-10-06 09:02:15 +02:00
Mateusz Kwasniewski
c65a336783
feat: milestone start time update (#10730) 2025-10-03 14:09:49 +02:00
Mateusz Kwasniewski
f670505e56
feat: milestones started at migration (#10729) 2025-10-03 13:38:32 +02:00
Mateusz Kwasniewski
3ef2a7f93b
feat: add histogram to impact metrics (#10728) 2025-10-03 10:13:12 +02:00
Gastón Fournier
a927f1f42b
chore: new method that considers users updated at the same time (#10723)
We could have users updated at the exact same time, so we need to
include that timestamp in the next fetch to avoid missing users, but
also include the latest user id so we can exclude the ones already
fetched.

The following test shows how to process pages with this new method:

c03df86ee0/src/lib/features/users/user-updates-read-model.test.ts (L39-L65)
2025-10-03 09:24:53 +02:00
Tymoteusz Czech
9b5324ac92
feat: flag traffic billing display feature (#10718)
Feature flag and initial changes in Billing UI
2025-10-03 09:18:39 +02:00
Mateusz Kwasniewski
6c6d4c0ccc
chore: milestone progression flag (#10719) 2025-10-02 14:28:37 +02:00
Gastón Fournier
fb5d4cc7a1
fix: constraints should not be null (#10717)
## About the changes
In our code, we're not expecting constraints to be null:
https://github.com/search?q=repo%3AUnleash%2Funleash%20jsonb_array_elements(constraints)&type=code

It's unlikely to get a null value in constraints when using our API or
UI, but there might be cases where this can happen, as we saw in our
logs:
```
error: select "context_fields"."name", "context_fields"."description", "context_fields"."stickiness", "context_fields"."sort_order", "context_fields"."legal_values", "context_fields"."created_at", COUNT(DISTINCT CASE
                        WHEN features.archived_at IS NULL
                        THEN feature_strategies.project_name
                    END) AS used_in_projects, COUNT(DISTINCT CASE
                        WHEN features.archived_at IS NULL
                        THEN feature_strategies.feature_name
                    END) AS used_in_features from "context_fields" LEFT JOIN feature_strategies ON EXISTS (
                        SELECT 1
                        FROM jsonb_array_elements(feature_strategies.constraints) AS elem
                        WHERE elem ->> 'contextName' = context_fields.name
                      ) left join "features" on "features"."name" = "feature_strategies"."feature_name" group by "context_fields"."name", "context_fields"."description", "context_fields"."stickiness", "context_fields"."sort_order", "context_fields"."created_at" order by "name" asc - cannot extract elements from a scalar
```
which is likely due to:
`jsonb_array_elements(feature_strategies.constraints)` with null
constraints

For this reason, it seems reasonable to enforce the constraint at the
database level.
2025-10-02 12:45:53 +02:00
unleash-bot[bot]
da22cb0d65
chore(AI): etagVariant flag cleanup (#10714)
This PR cleans up the etagVariant flag. These changes were automatically
generated by AI and should be reviewed carefully.

Fixes #10711

## 🧹 AI Flag Cleanup Summary
This PR removes the `etagVariant` feature flag, making the versioned
ETag format
(`v2`) the default and only behavior for the client features API.
### 🚮 Removed
- **Feature Flag**
- Removed the `etagVariant` flag definition from `experimental.ts`.
- Removed conditional logic for ETag generation in
`client-feature-toggle.controller.ts`.
- **Testing**
- Removed parameterized tests for both states of the flag in
`feature.optimal304.e2e.test.ts`.
- Removed configuration of the `etagVariant` flag in test setup.
### 🛠 Kept
- **ETag Generation**
- The logic to generate ETags with a version suffix (`v1`) is now the
standard
behavior.
- **Testing**
- Tests have been updated to exclusively assert the presence of the `v1`
suffix in ETags.
### 📝 Why
The `etagVariant` feature flag has been successfully rolled out and is
now
considered complete. By removing the flag, we are simplifying the
codebase by
eliminating conditional paths and making the improved ETag format
permanent.
This change ensures all client API responses for features include a
versioned
ETag, which helps with cache-busting when the ETag format changes in the
future.

---------

Co-authored-by: unleash-bot <194219037+unleash-bot[bot]@users.noreply.github.com>
Co-authored-by: Gastón Fournier <gaston@getunleash.io>
2025-10-02 11:26:53 +02:00
Tymoteusz Czech
c7eb79038e
chore: add flags for UI filter refactor (#10708) 2025-10-01 09:20:25 +00:00
Nuno Góis
7462465a0b
chore: resource limits service (#10709)
https://linear.app/unleash/issue/2-3927/implement-resource-limits-service

Implements a resource limits service.

The implementation looks trivial (or even redundant) in OSS, but by
implementing a resource limits service we can make this potentially
dynamic and overridable.
2025-10-01 09:57:18 +01:00
Nuno Góis
e46f8881d1
chore: extract UI config logic into its own service (#10704)
https://linear.app/unleash/issue/2-3921/extract-ui-config-logic-into-its-own-service

Extracts UI config logic into its own service.

This is the first step to accomplish resource limits and license key
resources alignment.
2025-09-30 11:04:20 +01:00
Gastón Fournier
e0cdf6addd
feat: add users updated read model (#10693)
## About the changes
This adds a user read model using the updated_at new field in the users
table.
2025-09-24 17:39:03 +02:00
Mateusz Kwasniewski
413847374e
feat: using histogram metrics (#10695) 2025-09-24 17:02:29 +02:00
Mateusz Kwasniewski
3bb317ad6d
feat: node sdk with histogram (#10690) 2025-09-24 14:17:16 +02:00
Gastón Fournier
907727947a
Revert "feat: enforce email null when deleted is set" (#10682)
Reverts Unleash/unleash#10680

SCIM protocol requires us to keep the email stored, so this constraint
doesn't hold.
2025-09-23 17:25:39 +02:00
Gastón Fournier
d33e57a05f
feat: enforce email null when deleted is set (#10680)
## About the changes
When deleting a user we set the email to null and deleted_at to the
current date, there's no case where email is set and deleted_at is also
set.

We found some situations where this happens, specifically when SAML and
SCIM are used in conjunction
2025-09-23 14:43:53 +02:00
Gastón Fournier
a628755506
fix: SSO auto create with SCIM tend to override each other (#10675)
## About the changes
Having SCIM enabled with SAML and auto-create can generate issues with
each protocol stepping into the other protocol's toes.

This PR adds protection to avoid updating SCIM-managed users with SAML
data (cause SCIM will override this data later).

It also adds a new method in the store to check if we have cases where
deleted_at is set but the email is not cleared, and there's no delete
event in the audit log (we've found one case, and we believe it might be
related to interoperability issues between SAML and SCIM)
2025-09-22 17:55:22 +02:00
Mateusz Kwasniewski
8d03ce340d
feat: histogram impact metric ingestion (#10674) 2025-09-22 17:14:07 +02:00
Mateusz Kwasniewski
3296add50f
feat: batch histogram metric type (#10672) 2025-09-22 13:22:53 +02:00
David Leek
831b4541a9
fix: OSS export feature_env was always enabled for feature due to SQL join overwrite (#10667) 2025-09-18 10:01:25 +02:00
Nuno Góis
c2f6cfe45f
chore: remove AWS IAM DB auth prototype code (#10662)
https://linear.app/unleash/issue/2-3882/remove-aws-iam-db-auth-prototype-code

Removes the AWS IAM DB auth prototype code.

Related PRs:
- https://github.com/Unleash/unleash/pull/10609
- https://github.com/Unleash/unleash/pull/10617
- https://github.com/Unleash/unleash/pull/10622
- https://github.com/Unleash/unleash/pull/10635
- https://github.com/Unleash/unleash/pull/10639
- https://github.com/Unleash/unleash/pull/10643
2025-09-12 14:46:28 +01:00
Thomas Heartman
0ea006f72c
Add globalChangeRequestList flag to Unleash (#10645)
Add a flag for the new CR list feature.
2025-09-10 11:11:10 +00:00
Nuno Góis
86530bcfbd
chore: add proxy-aware regional STS authentication for AWS IAM DB auth (#10643)
https://linear.app/unleash/issue/2-3875/add-proxy-aware-regional-sts-authentication-for-aws-iam-db-auth

Adds proxy-aware regional STS authentication for AWS IAM DB auth.

We also added optional support for explicit IAM role assumption through
the `DATABASE_AWS_ROLE_ARN` environment variable.
2025-09-10 10:50:39 +01:00
Nuno Góis
7cec4d6923
chore: remove DB access checker (#10639)
Reverts our latest changes regarding debug logs.
2025-09-09 15:55:32 +01:00
Nuno Góis
71b0d424b8
chore: correctly import pg client (#10637)
Follow-up to: https://github.com/Unleash/unleash/pull/10635

Correctly imports pg client.
2025-09-09 13:38:14 +01:00
Nuno Góis
e3bc72483a
chore: add verbose logs to AWS IAM auth logic, add DB access checker (#10635)
https://linear.app/unleash/issue/2-3874/add-verbose-logs-to-aws-iam-auth-logic-including-a-db-access-checker

Adds verbose logs to our new AWS IAM DB auth logic. Also adds a DB
access checker that runs before our migrator and fails fast in case
something is wrong with DB access.

This should not affect the regular auth path.
2025-09-09 13:08:36 +01:00
Nuno Góis
b8cdd1d004
chore: add newStrategyModal flag (#10629)
https://linear.app/unleash/issue/2-3865/add-newstrategymodal-feature-flag

Adds `newStrategyModal` feature flag.

The approach here is to duplicate the existing
`FeatureStrategyMenuCards` into a `LegacyFeatureStrategyMenuCards`.
We'll continue working on the `FeatureStrategyMenuCards` component while
leaving `LegacyFeatureStrategyMenuCards` untouched. Once we're done with
the implementation and remove the flag we can drop the legacy file.

I think it's easier to reduce our add strategy buttons to a single one
right away (like we did with the `addConfiguration` flag in
https://github.com/Unleash/unleash/pull/10420). This allows us to focus
on the end result instead of having to implement things like "clicking
the 'add release template' button should show the modal filtered to only
release templates".

<img width="735" height="126" alt="image"
src="https://github.com/user-attachments/assets/6d10fab2-d091-40f3-9c36-05a6f28f7dda"
/>

<img width="995" height="742" alt="image"
src="https://github.com/user-attachments/assets/a0fb9366-89b5-44e1-a684-47ee30d6d36c"
/>
2025-09-08 12:16:27 +01:00
unleash-bot[bot]
9540ed6e3d
chore(AI): addConfiguration flag cleanup (#10628)
This PR cleans up the addConfiguration flag. These changes were
automatically generated by AI and should be reviewed carefully.

Fixes #10627

## 🧹 AI Flag Cleanup Summary
This change removes the `addConfiguration` feature flag. The feature was
discarded, so this cleanup reverts the UI to its state before the
`addConfiguration` flag was introduced. The primary change is in the
strategy
menu, where the single "Add configuration" button is removed and the
original
"Use template," "Add strategy," and "More" buttons are restored.
### 🚮 Removed
- **Flag Definitions**
- `addConfiguration` flag from `experimental.ts` on the backend.
- `addConfiguration` flag from `uiConfig.ts` on the frontend.
- `addConfiguration: true` from the `server-dev.ts` config.
- **UI Components & Logic**
- The conditional rendering in `FeatureStrategyMenu.tsx` that showed an
"Add
configuration" button.
- The `useUiFlag('addConfiguration')` hook call and its import from
`FeatureStrategyMenu.tsx`.
### 🛠 Kept
- **UI Components & Logic**
- The original set of buttons in `FeatureStrategyMenu.tsx`: "Use
template",
"Add strategy", and a "More strategies" icon button. This was the code
path for
when the flag was disabled.
### 📝 Why
The `addConfiguration` feature flag was marked as completed with the
outcome
"discarded". This cleanup removes the flag and all related code,
preserving only
the intended code path, which is the UI behavior from before the flag
was
introduced.

---------

Co-authored-by: unleash-bot <194219037+unleash-bot[bot]@users.noreply.github.com>
Co-authored-by: Nuno Góis <github@nunogois.com>
2025-09-08 07:38:10 -03:00
Nuno Góis
39ee5b97cb
chore: AWS IAM DB auth migrator (#10622)
https://linear.app/unleash/issue/2-3861/aws-iam-db-auth-migrator

Adapts the migrator logic to support AWS IAM DB auth.

Reverts a few changes from our earlier tests.
2025-09-04 16:14:02 +01:00
Mateusz Kwasniewski
ccaafb3716
feat: added new impact metrics events (#10621) 2025-09-04 15:32:41 +02:00
Nuno Góis
9388ef66d0
chore: IAM auth username env var takes precedence (#10618) 2025-09-04 15:01:27 +02:00
Nuno Góis
07f6970eed
chore: AWS IAM DB auth migrator, logs (#10617)
https://linear.app/unleash/issue/2-3860/aws-iam-db-auth-migrator-logs

AWS IAM DB auth migrator, logs.
2025-09-04 14:03:24 +02:00
Nuno Góis
6a8a6e2373
chore: add IAM db auth support (#10609)
https://linear.app/unleash/issue/2-3829/investigate-aws-iam-connection-support-for-unleash-docker

Adds AWS IAM DB connection support.
2025-09-04 10:29:43 +01:00
Mateusz Kwasniewski
9f90603bea
chore: bring back variant config (#10608) 2025-09-03 13:05:36 +02:00
Mateusz Kwasniewski
0c1fc54d62
fix: flag resolver isEnabled for variant configs (#10607) 2025-09-03 12:43:56 +02:00
Mateusz Kwasniewski
29133a9fc9
chore: revert original streaming config (#10606) 2025-09-03 12:25:18 +02:00
Mateusz Kwasniewski
5b74299420
chore: control streaming only with external resolver (#10605) 2025-09-03 11:41:33 +02:00
Mateusz Kwasniewski
277326c952
chore: allow streaming variant override (#10603) 2025-09-03 10:51:16 +02:00
Nuno Góis
d5f834e851
chore: add unknown flag metric for unique flag names (#10601)
https://linear.app/unleash/issue/2-3845/add-metric-for-unique-unknown-flag-names

Adds a new unknown flag metric for unique unknown flag names.

<img width="864" height="126" alt="image"
src="https://github.com/user-attachments/assets/c20ce53e-eff3-4cda-af4b-f2c2aae8575c"
/>
2025-09-03 08:44:28 +01:00
unleash-bot[bot]
dfa89d7d58
chore(AI): reportUnknownFlags flag cleanup (#10596)
This PR cleans up the reportUnknownFlags flag. These changes were
automatically generated by AI and should be reviewed carefully.

Fixes #10595

## 🧹 AI Flag Cleanup Summary
This change removes the `reportUnknownFlags` feature flag and makes its
functionality a permanent part of the application. The "Unknown flags"
feature
is now always enabled.
### 🚮 Removed
- **Flag Definitions**
- Removed `reportUnknownFlags` from `IFlagKey` and `UiFlags` types.
- Removed `reportUnknownFlags` from the experimental flags configuration
in `src/lib/types/experimental.ts`.
- Removed the flag from development and test configurations
(`src/server-dev.ts`, `unknown-flags.e2e.test.ts`).
- **Conditional Logic**
- Removed conditional checks for `reportUnknownFlags` in backend
services
(`UnknownFlagsService`, `ClientMetricsServiceV2`) and API controllers
(`UnknownFlagsController`).
- Removed `useUiFlag('reportUnknownFlags')` and related conditional
rendering from frontend components (`UnknownFlagsTable`,
`FeatureToggleListTable`). The UI elements are now always visible.
- Modified the `useUnknownFlags` hook to always fetch data.
### 🛠 Kept
- **Core Functionality**
- The feature to report and display unknown flags is now always active.
- The "Unknown flags" link is now permanently visible on the feature
flags
overview page.
- Backend logic for processing and storing unknown flags is now always
executed.
### 📝 Why
The `reportUnknownFlags` feature flag was marked as completed with the
feature
being kept. This cleanup removes the flag and its associated conditional
logic,
simplifying the code and making the unknown flags reporting a permanent
feature.

---------

Co-authored-by: unleash-bot <194219037+unleash-bot[bot]@users.noreply.github.com>
Co-authored-by: Nuno Góis <github@nunogois.com>
2025-09-02 14:18:35 +01:00
Mateusz Kwasniewski
e9f651e2f5
feat: impact metrics migration (#10551) 2025-09-02 13:40:34 +02:00
Jaanus
6c11b57c53
fix: remove lifecycle backfill on every startup 2025-09-02 13:55:18 +03:00