Skip to content

Commit bc5d07d

Browse files
authored
Merge branch 'main' into feat/environment-document-identity-overrides
2 parents 28f03f1 + 7e631f5 commit bc5d07d

File tree

124 files changed

+5793
-1912
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

124 files changed

+5793
-1912
lines changed

.github/workflows/api-audit.yml

+4-3
Original file line numberDiff line numberDiff line change
@@ -17,13 +17,14 @@ jobs:
1717
- name: Cloning repo
1818
uses: actions/checkout@v4
1919

20-
- name: Set up Python 3.11
20+
- name: Set up Python 3.12
2121
uses: actions/setup-python@v5
2222
with:
23-
python-version: '3.11'
23+
python-version: '3.12'
2424

25+
# Ignore CVE-2023-6129 as per https://github.com/pyca/pyopenssl/issues/1300
2526
- name: Run Audit
2627
run: |
2728
make install
2829
poetry self add poetry-audit-plugin==0.4.0
29-
poetry audit
30+
poetry audit --ignore-code=CVE-2023-6129

.github/workflows/api-merge.yml

+2-7
Original file line numberDiff line numberDiff line change
@@ -23,11 +23,6 @@ jobs:
2323
ports: ['5432:5432']
2424
options: --health-cmd pg_isready --health-interval 10s --health-timeout 5s --health-retries 5
2525

26-
strategy:
27-
max-parallel: 2
28-
matrix:
29-
python-version: ['3.10', '3.11']
30-
3126
steps:
3227
- name: Cloning repo
3328
uses: actions/checkout@v4
@@ -37,7 +32,7 @@ jobs:
3732

3833
- uses: actions/setup-python@v5
3934
with:
40-
python-version: ${{ matrix.python-version }}
35+
python-version: 3.12
4136
cache: 'poetry'
4237

4338
- name: Install Dependencies
@@ -66,7 +61,7 @@ jobs:
6661
- name: Upload Coverage
6762
uses: codecov/codecov-action@v4
6863
env:
69-
PYTHON: ${{ matrix.python-version }}
64+
PYTHON: '3.12'
7065
with:
7166
token: ${{ secrets.CODECOV_TOKEN }}
7267
env_vars: PYTHON

.github/workflows/api-pull-request.yml

+2-7
Original file line numberDiff line numberDiff line change
@@ -32,11 +32,6 @@ jobs:
3232
ports: ['5432:5432']
3333
options: --health-cmd pg_isready --health-interval 10s --health-timeout 5s --health-retries 5
3434

35-
strategy:
36-
max-parallel: 2
37-
matrix:
38-
python-version: ['3.10', '3.11', '3.12']
39-
4035
steps:
4136
- name: Cloning repo
4237
uses: actions/checkout@v4
@@ -46,7 +41,7 @@ jobs:
4641

4742
- uses: actions/setup-python@v5
4843
with:
49-
python-version: ${{ matrix.python-version }}
44+
python-version: 3.12
5045
cache: 'poetry'
5146

5247
- name: Install Dependencies
@@ -75,7 +70,7 @@ jobs:
7570
- name: Upload Coverage
7671
uses: codecov/codecov-action@v4
7772
env:
78-
PYTHON: ${{ matrix.python-version }}
73+
PYTHON: 3.12
7974
with:
8075
token: ${{ secrets.CODECOV_TOKEN }}
8176
env_vars: PYTHON

.github/workflows/api-tests-with-private-packages.yml

+1-6
Original file line numberDiff line numberDiff line change
@@ -34,11 +34,6 @@ jobs:
3434
ports: ['5432:5432']
3535
options: --health-cmd pg_isready --health-interval 10s --health-timeout 5s --health-retries 5
3636

37-
strategy:
38-
max-parallel: 4
39-
matrix:
40-
python-version: ['3.10', '3.11']
41-
4237
steps:
4338
- name: Cloning repo
4439
uses: actions/checkout@v4
@@ -47,7 +42,7 @@ jobs:
4742
run: pipx install poetry
4843
- uses: actions/setup-python@v5
4944
with:
50-
python-version: ${{ matrix.python-version }}
45+
python-version: '3.12'
5146
cache: 'poetry'
5247

5348
- name: Install Dependencies

.github/workflows/update-flagsmith-environment.yml

+2-2
Original file line numberDiff line numberDiff line change
@@ -19,10 +19,10 @@ jobs:
1919
steps:
2020
- uses: actions/checkout@v4
2121

22-
- name: Set up Python 3.11
22+
- name: Set up Python 3.12
2323
uses: actions/setup-python@v5
2424
with:
25-
python-version: 3.11
25+
python-version: 3.12
2626
cache: pip
2727

2828
- name: Install Dependencies

.release-please-manifest.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
11
{
2-
".": "2.107.4"
2+
".": "2.109.0"
33
}

CHANGELOG.md

+40
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,45 @@
11
# Changelog
22

3+
## [2.109.0](https://github.com/Flagsmith/flagsmith/compare/v2.108.1...v2.109.0) (2024-04-23)
4+
5+
6+
### Features
7+
8+
* Ability to customise default environments for new project ([#3655](https://github.com/Flagsmith/flagsmith/issues/3655)) ([cfb5748](https://github.com/Flagsmith/flagsmith/commit/cfb57484597274506f44c86ec4f089b1fe4c0f14))
9+
* Report database errors when waiting for database in entrypoint ([#3823](https://github.com/Flagsmith/flagsmith/issues/3823)) ([a66c262](https://github.com/Flagsmith/flagsmith/commit/a66c262bf169ed887418338efc735eee79884e87))
10+
* Show organisation name in header ([#3808](https://github.com/Flagsmith/flagsmith/issues/3808)) ([10b14fd](https://github.com/Flagsmith/flagsmith/commit/10b14fd6a73462305087832ed750752b3157be80))
11+
* Show organisation name in HTML title ([#3814](https://github.com/Flagsmith/flagsmith/issues/3814)) ([ccfe3c3](https://github.com/Flagsmith/flagsmith/commit/ccfe3c3ddea9cd7123e4576428c6a79c15ae5f5a))
12+
* stale flags (FE) ([#3606](https://github.com/Flagsmith/flagsmith/issues/3606)) ([424b754](https://github.com/Flagsmith/flagsmith/commit/424b754cbdfdb079c76de7c890848884402b6ed2))
13+
14+
15+
### Bug Fixes
16+
17+
* archived persistence ([#3802](https://github.com/Flagsmith/flagsmith/issues/3802)) ([40363dc](https://github.com/Flagsmith/flagsmith/commit/40363dc8171520bee32227056c0496f283647b52))
18+
* broken link in New Segment modal ([#3820](https://github.com/Flagsmith/flagsmith/issues/3820)) ([97c5db7](https://github.com/Flagsmith/flagsmith/commit/97c5db7f9649077b230c19e67b2b4243d3478319))
19+
* master api key org api access ([#3817](https://github.com/Flagsmith/flagsmith/issues/3817)) ([cae2eac](https://github.com/Flagsmith/flagsmith/commit/cae2eacf2325cc3d6c4b6b590e3046fe0513844d))
20+
* Set error value from validation exception properly for feature seralizer ([#3809](https://github.com/Flagsmith/flagsmith/issues/3809)) ([18d8214](https://github.com/Flagsmith/flagsmith/commit/18d8214c760ee02a0b05ccc647868bbabc044a25))
21+
22+
## [2.108.1](https://github.com/Flagsmith/flagsmith/compare/v2.108.0...v2.108.1) (2024-04-18)
23+
24+
25+
### Bug Fixes
26+
27+
* prevent unauthorised remove-users access ([#3791](https://github.com/Flagsmith/flagsmith/issues/3791)) ([05353a5](https://github.com/Flagsmith/flagsmith/commit/05353a5fbe661d504abdede8875f450c4cc8dce5))
28+
29+
## [2.108.0](https://github.com/Flagsmith/flagsmith/compare/v2.107.4...v2.108.0) (2024-04-17)
30+
31+
32+
### Features
33+
34+
* Swagger schema for environment document ([#3789](https://github.com/Flagsmith/flagsmith/issues/3789)) ([dd89326](https://github.com/Flagsmith/flagsmith/commit/dd893262cff97a1b301a346737c106afc58bc146))
35+
36+
37+
### Bug Fixes
38+
39+
* edge API not updated when versioned change request committed ([#3760](https://github.com/Flagsmith/flagsmith/issues/3760)) ([a7ee657](https://github.com/Flagsmith/flagsmith/commit/a7ee6578b5923c9f85527a022f88b1aaa0fe5a04))
40+
* handle InfluxDBError when writing data ([#3788](https://github.com/Flagsmith/flagsmith/issues/3788)) ([1eaa823](https://github.com/Flagsmith/flagsmith/commit/1eaa823d3b7a2167ba424c83838bb72a4b2ec7ad))
41+
* odd behaviour seen when using REPLICA_DATABASE_URLS ([#3771](https://github.com/Flagsmith/flagsmith/issues/3771)) ([ec9e8ab](https://github.com/Flagsmith/flagsmith/commit/ec9e8ab30d224042e1bc07c00355f7b3e1b3977a))
42+
343
## [2.107.4](https://github.com/Flagsmith/flagsmith/compare/v2.107.3...v2.107.4) (2024-04-17)
444

545

api/.env-ci

+2-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
DATABASE_URL=postgresql://postgres:postgres@localhost:5432/postgres
22
ANALYTICS_DATABASE_URL=postgres://postgres:postgres@localhost:5432/analytics
3-
PYTEST_ADDOPTS=--cov . --cov-report xml -n auto --dist worksteal
3+
PYTEST_ADDOPTS=--cov . --cov-report xml -n auto --dist worksteal --ci
44
GUNICORN_LOGGER_CLASS=util.logging.GunicornJsonCapableLogger
5+
COVERAGE_CORE=sysmon

api/.env-local

-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
11
DATABASE_URL=postgresql://postgres:password@localhost:5432/flagsmith
22
DJANGO_SETTINGS_MODULE=app.settings.local
33
PYTEST_ADDOPTS=--cov . --cov-report html -n auto
4-
GUNICORN_LOGGER_CLASS=util.logging.GunicornJsonCapableLogger

api/Makefile

+2
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,8 @@ DOTENV_OVERRIDE_FILE ?= .env
99

1010
POETRY_VERSION ?= 1.8.2
1111

12+
GUNICORN_LOGGER_CLASS ?= util.logging.GunicornJsonCapableLogger
13+
1214
-include .env-local
1315
-include $(DOTENV_OVERRIDE_FILE)
1416

api/api_keys/user.py

+21-1
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
from django.db.models import QuerySet
44

5-
from organisations.models import Organisation
5+
from organisations.models import Organisation, OrganisationRole
66
from permissions.permission_service import (
77
get_permitted_environments_for_master_api_key,
88
get_permitted_projects_for_master_api_key,
@@ -35,9 +35,29 @@ def pk(self) -> str:
3535
def is_master_api_key_user(self) -> bool:
3636
return True
3737

38+
@property
39+
def organisations(self) -> QuerySet[Organisation]:
40+
return Organisation.objects.filter(id=self.key.organisation_id)
41+
3842
def belongs_to(self, organisation_id: int) -> bool:
3943
return self.key.organisation_id == organisation_id
4044

45+
def is_organisation_admin(
46+
self, organisation: typing.Union["Organisation", int]
47+
) -> bool:
48+
org_id = organisation.id if hasattr(organisation, "id") else organisation
49+
return self.key.is_admin and self.key.organisation_id == org_id
50+
51+
def get_organisation_role(self, organisation: Organisation) -> typing.Optional[str]:
52+
if self.key.organisation_id != organisation.id:
53+
return None
54+
55+
return (
56+
OrganisationRole.ADMIN.value
57+
if self.key.is_admin
58+
else OrganisationRole.USER.value
59+
)
60+
4161
def is_project_admin(self, project: "Project") -> bool:
4262
return is_master_api_key_project_admin(self.key, project)
4363

api/app/settings/common.py

+7-23
Original file line numberDiff line numberDiff line change
@@ -125,6 +125,7 @@
125125
"permissions",
126126
"projects.tags",
127127
"api_keys",
128+
"features.feature_external_resources",
128129
# 2FA
129130
"trench",
130131
# health check plugins
@@ -147,6 +148,7 @@
147148
"integrations.dynatrace",
148149
"integrations.flagsmith",
149150
"integrations.launch_darkly",
151+
"integrations.github",
150152
# Rate limiting admin endpoints
151153
"axes",
152154
"telemetry",
@@ -887,6 +889,10 @@
887889
# Slack Integration
888890
SLACK_CLIENT_ID = env.str("SLACK_CLIENT_ID", default="")
889891
SLACK_CLIENT_SECRET = env.str("SLACK_CLIENT_SECRET", default="")
892+
# GitHub integrations
893+
GITHUB_PEM = env.str("GITHUB_PEM", default="")
894+
GITHUB_APP_ID: int = env.int("GITHUB_APP_ID", default=0)
895+
890896

891897
# MailerLite
892898
MAILERLITE_BASE_URL = env.str(
@@ -1037,29 +1043,7 @@
10371043
HUBSPOT_IGNORE_DOMAINS = env.list("HUBSPOT_IGNORE_DOMAINS", [])
10381044
HUBSPOT_IGNORE_DOMAINS_REGEX = env("HUBSPOT_IGNORE_DOMAINS_REGEX", "")
10391045
HUBSPOT_IGNORE_ORGANISATION_DOMAINS = env.list(
1040-
"HUBSPOT_IGNORE_ORGANISATION_DOMAINS",
1041-
[
1042-
"126.com",
1043-
"163.com",
1044-
"aol.com",
1045-
"att.net",
1046-
"comcast.net",
1047-
"gmail.com",
1048-
"gmx.com",
1049-
"hotmail.com",
1050-
"icloud.com",
1051-
"live.com",
1052-
"mail.com",
1053-
"mail.ru",
1054-
"outlook.co.uk",
1055-
"outlook.com",
1056-
"protonmail.com",
1057-
"qq.com",
1058-
"sina.com",
1059-
"yahoo.com",
1060-
"yandex.com",
1061-
"zoho.com",
1062-
],
1046+
"HUBSPOT_IGNORE_ORGANISATION_DOMAINS", []
10631047
)
10641048

10651049
# List of plan ids that support seat upgrades

api/app_analytics/influxdb_wrapper.py

+7-2
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44

55
from django.conf import settings
66
from influxdb_client import InfluxDBClient, Point
7+
from influxdb_client.client.exceptions import InfluxDBError
78
from influxdb_client.client.write_api import SYNCHRONOUS
89
from sentry_sdk import capture_exception
910
from urllib3 import Retry
@@ -61,8 +62,12 @@ def add_data_point(self, field_name, field_value, tags=None):
6162
def write(self):
6263
try:
6364
self.write_api.write(bucket=settings.INFLUXDB_BUCKET, record=self.records)
64-
except HTTPError:
65-
logger.warning("Failed to write records to Influx.")
65+
except (HTTPError, InfluxDBError) as e:
66+
logger.warning(
67+
"Failed to write records to Influx: %s",
68+
str(e),
69+
exc_info=e,
70+
)
6671
logger.debug(
6772
"Records: %s. Bucket: %s",
6873
self.records,

0 commit comments

Comments
 (0)