Skip to content

Commit cb9af5e

Browse files
DanielRyanSmithDanielRyanSmith
andauthored
Allow bypassing OT Chromium checks in non-prod environments (#4705)
* Allow bypassing OT Chromium checks on staging * revert package.json change * fix bypass logic in use counter value function * fix test --------- Co-authored-by: DanielRyanSmith <[email protected]>
1 parent 5fed1ad commit cb9af5e

File tree

11 files changed

+119
-12
lines changed

11 files changed

+119
-12
lines changed

api/origin_trials_api.py

Lines changed: 14 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@
2929
from internals.core_enums import OT_READY_FOR_CREATION
3030
from internals.core_models import FeatureEntry, Stage
3131
from internals.review_models import Gate, Vote
32+
import settings
3233

3334
WEBFEATURE_FILE_URL = 'https://chromium.googlesource.com/chromium/src/+/main/third_party/blink/public/mojom/use_counter/metrics/web_feature.mojom?format=TEXT'
3435
WEBDXFEATURE_FILE_URL = 'https://chromium.googlesource.com/chromium/src/+/main/third_party/blink/public/mojom/use_counter/metrics/webdx_feature.mojom?format=TEXT'
@@ -66,6 +67,10 @@ def get_chromium_files_for_validation() -> dict:
6667
def find_use_counter_value(
6768
body: dict, chromium_files_dict: dict) -> int | None:
6869
"""Find where the use counter is defined and return its value."""
70+
# Chromium file checks can be bypassed, but only in non-prod environments.
71+
if (not settings.PROD and body['ot_creation__bypass_file_checks'] and
72+
body['ot_creation__bypass_file_checks']['value']):
73+
return 0
6974
use_counter_name = body.get(
7075
'ot_webfeature_use_counter', {}).get('value')
7176
webfeature_use_counter = body.get(
@@ -225,12 +230,15 @@ def do_post(self, **kwargs):
225230
except Exception as exc:
226231
self.abort(
227232
500, f'Error obtaining Chromium file for validation: {str(exc)}')
228-
validation_errors = self._validate_creation_args(body, chromium_files_dict)
229-
if validation_errors:
230-
return {
231-
'message': 'Errors found when validating arguments',
232-
'errors': validation_errors
233-
}
233+
# Chromium file checks can be bypassed, but only in non-prod environments.
234+
if (settings.PROD or not body['ot_creation__bypass_file_checks'] or
235+
not body['ot_creation__bypass_file_checks']['value']):
236+
validation_errors = self._validate_creation_args(body, chromium_files_dict)
237+
if validation_errors:
238+
return {
239+
'message': 'Errors found when validating arguments',
240+
'errors': validation_errors
241+
}
234242
self.update_stage(ot_stage, body, [])
235243
ot_stage.ot_use_counter_bucket_number = find_use_counter_value(body, chromium_files_dict)
236244

client-src/elements/chromedash-ot-creation-page.ts

Lines changed: 17 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -199,15 +199,29 @@ export class ChromedashOTCreationPage extends LitElement {
199199
);
200200
}
201201

202-
addHiddenFields() {
203-
// Add a field for updating that an OT creation request has been submitted.
202+
addAdditionalFields() {
203+
// Add a hidden field for updating that an OT creation request has been submitted.
204204
this.fieldValues.push({
205205
name: 'ot_action_requested',
206206
touched: true,
207207
value: true,
208208
stageId: this.stage.id,
209209
alwaysHidden: true,
210210
});
211+
212+
// For non-prod environments, add a checkbox to bypass the checks ensuring
213+
// that all values exist in Chromium files.
214+
// TODO(DanielRyanSmith): Identify non-prod environments using a flag rather
215+
// than the app's title.
216+
if (this.appTitle !== 'Chrome Platform Status') {
217+
this.fieldValues.push({
218+
name: 'ot_creation__bypass_file_checks',
219+
touched: true,
220+
value: false,
221+
stageId: this.stage.id,
222+
alwaysHidden: false,
223+
});
224+
}
211225
}
212226

213227
// Create the array that tracks the value of fields.
@@ -236,7 +250,7 @@ export class ChromedashOTCreationPage extends LitElement {
236250
};
237251
});
238252
this.addOptionalApprovalsFields();
239-
this.addHiddenFields();
253+
this.addAdditionalFields();
240254
}
241255

242256
disconnectedCallback() {

client-src/elements/form-field-enums.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -404,6 +404,7 @@ export const STAGE_SPECIFIC_FIELDS = new Set<string>([
404404
'ot_request_note',
405405
'ot_webfeature_use_counter',
406406
'ot_documentation_url',
407+
'ot_creation__bypass_file_checks',
407408
'ot_creation__ot_documentation_url',
408409
'ot_is_deprecation_trial',
409410
'ot_has_third_party_support',

client-src/elements/form-field-specs.ts

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1653,6 +1653,15 @@ export const ALL_FIELDS: Record<string, Field> = {
16531653
checkMilestoneRanges([OT_MILESTONE_DESKTOP_RANGE], getFieldValue),
16541654
},
16551655

1656+
ot_creation__bypass_file_checks: {
1657+
type: 'checkbox',
1658+
initial: false,
1659+
label: 'Bypass Chromium file checks (staging testing)',
1660+
help_text: html`This option should only be visible in ChromeStatus staging
1661+
environments. Allow this form to be submitted without verifying Chromium
1662+
code has landed.`,
1663+
},
1664+
16561665
anticipated_spec_changes: {
16571666
type: 'textarea',
16581667
attrs: {rows: 4},

gen/js/chromestatus-openapi/src/models/CreateOriginTrialRequest.ts

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -140,6 +140,12 @@ export interface CreateOriginTrialRequest {
140140
* @memberof CreateOriginTrialRequest
141141
*/
142142
ot_action_requested?: FieldInfo;
143+
/**
144+
*
145+
* @type {FieldInfo}
146+
* @memberof CreateOriginTrialRequest
147+
*/
148+
ot_creation__bypass_file_checks?: FieldInfo;
143149
/**
144150
*
145151
* @type {FieldInfo}
@@ -316,6 +322,7 @@ export function CreateOriginTrialRequestFromJSONTyped(json: any, ignoreDiscrimin
316322
'ot_chromium_trial_name': json['ot_chromium_trial_name'] == null ? undefined : FieldInfoFromJSON(json['ot_chromium_trial_name']),
317323
'ot_display_name': json['ot_display_name'] == null ? undefined : FieldInfoFromJSON(json['ot_display_name']),
318324
'ot_action_requested': json['ot_action_requested'] == null ? undefined : FieldInfoFromJSON(json['ot_action_requested']),
325+
'ot_creation__bypass_file_checks': json['ot_creation__bypass_file_checks'] == null ? undefined : FieldInfoFromJSON(json['ot_creation__bypass_file_checks']),
319326
'ot_documentation_url': json['ot_documentation_url'] == null ? undefined : FieldInfoFromJSON(json['ot_documentation_url']),
320327
'ot_emails': json['ot_emails'] == null ? undefined : FieldInfoFromJSON(json['ot_emails']),
321328
'ot_feedback_submission_url': json['ot_feedback_submission_url'] == null ? undefined : FieldInfoFromJSON(json['ot_feedback_submission_url']),
@@ -367,6 +374,7 @@ export function CreateOriginTrialRequestToJSON(value?: CreateOriginTrialRequest
367374
'ot_chromium_trial_name': FieldInfoToJSON(value['ot_chromium_trial_name']),
368375
'ot_display_name': FieldInfoToJSON(value['ot_display_name']),
369376
'ot_action_requested': FieldInfoToJSON(value['ot_action_requested']),
377+
'ot_creation__bypass_file_checks': FieldInfoToJSON(value['ot_creation__bypass_file_checks']),
370378
'ot_documentation_url': FieldInfoToJSON(value['ot_documentation_url']),
371379
'ot_emails': FieldInfoToJSON(value['ot_emails']),
372380
'ot_feedback_submission_url': FieldInfoToJSON(value['ot_feedback_submission_url']),

gen/js/chromestatus-openapi/src/models/StageField.ts

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -140,6 +140,12 @@ export interface StageField {
140140
* @memberof StageField
141141
*/
142142
ot_action_requested?: FieldInfo;
143+
/**
144+
*
145+
* @type {FieldInfo}
146+
* @memberof StageField
147+
*/
148+
ot_creation__bypass_file_checks?: FieldInfo;
143149
/**
144150
*
145151
* @type {FieldInfo}
@@ -268,6 +274,7 @@ export function StageFieldFromJSONTyped(json: any, ignoreDiscriminator: boolean)
268274
'ot_chromium_trial_name': json['ot_chromium_trial_name'] == null ? undefined : FieldInfoFromJSON(json['ot_chromium_trial_name']),
269275
'ot_display_name': json['ot_display_name'] == null ? undefined : FieldInfoFromJSON(json['ot_display_name']),
270276
'ot_action_requested': json['ot_action_requested'] == null ? undefined : FieldInfoFromJSON(json['ot_action_requested']),
277+
'ot_creation__bypass_file_checks': json['ot_creation__bypass_file_checks'] == null ? undefined : FieldInfoFromJSON(json['ot_creation__bypass_file_checks']),
271278
'ot_documentation_url': json['ot_documentation_url'] == null ? undefined : FieldInfoFromJSON(json['ot_documentation_url']),
272279
'ot_emails': json['ot_emails'] == null ? undefined : FieldInfoFromJSON(json['ot_emails']),
273280
'ot_feedback_submission_url': json['ot_feedback_submission_url'] == null ? undefined : FieldInfoFromJSON(json['ot_feedback_submission_url']),
@@ -311,6 +318,7 @@ export function StageFieldToJSON(value?: StageField | null): any {
311318
'ot_chromium_trial_name': FieldInfoToJSON(value['ot_chromium_trial_name']),
312319
'ot_display_name': FieldInfoToJSON(value['ot_display_name']),
313320
'ot_action_requested': FieldInfoToJSON(value['ot_action_requested']),
321+
'ot_creation__bypass_file_checks': FieldInfoToJSON(value['ot_creation__bypass_file_checks']),
314322
'ot_documentation_url': FieldInfoToJSON(value['ot_documentation_url']),
315323
'ot_emails': FieldInfoToJSON(value['ot_emails']),
316324
'ot_feedback_submission_url': FieldInfoToJSON(value['ot_feedback_submission_url']),

gen/py/chromestatus_openapi/chromestatus_openapi/models/create_origin_trial_request.py

Lines changed: 27 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ class CreateOriginTrialRequest(Model):
1414
Do not edit the class manually.
1515
"""
1616

17-
def __init__(self, announcement_url=None, browser=None, ot_description=None, display_name=None, enterprise_policies=None, finch_url=None, experiment_goals=None, experiment_risks=None, experiment_extension_reason=None, intent_thread_url=None, origin_trial_feedback_url=None, origin_trial_id=None, ot_approval_buganizer_component=None, ot_approval_buganizer_custom_field_id=None, ot_approval_criteria_url=None, ot_approval_group_email=None, ot_chromium_trial_name=None, ot_display_name=None, ot_action_requested=None, ot_documentation_url=None, ot_emails=None, ot_feedback_submission_url=None, ot_has_third_party_support=None, ot_is_critical_trial=None, ot_is_deprecation_trial=None, ot_owner_email=None, ot_request_note=None, ot_require_approvals=None, ot_stage_id=None, ot_webfeature_use_counter=None, rollout_impact=None, rollout_milestone=None, rollout_platforms=None, rollout_details=None, desktop_first=None, desktop_last=None, android_first=None, android_last=None, ios_first=None, ios_last=None, webview_first=None, webview_last=None): # noqa: E501
17+
def __init__(self, announcement_url=None, browser=None, ot_description=None, display_name=None, enterprise_policies=None, finch_url=None, experiment_goals=None, experiment_risks=None, experiment_extension_reason=None, intent_thread_url=None, origin_trial_feedback_url=None, origin_trial_id=None, ot_approval_buganizer_component=None, ot_approval_buganizer_custom_field_id=None, ot_approval_criteria_url=None, ot_approval_group_email=None, ot_chromium_trial_name=None, ot_display_name=None, ot_action_requested=None, ot_creation__bypass_file_checks=None, ot_documentation_url=None, ot_emails=None, ot_feedback_submission_url=None, ot_has_third_party_support=None, ot_is_critical_trial=None, ot_is_deprecation_trial=None, ot_owner_email=None, ot_request_note=None, ot_require_approvals=None, ot_stage_id=None, ot_webfeature_use_counter=None, rollout_impact=None, rollout_milestone=None, rollout_platforms=None, rollout_details=None, desktop_first=None, desktop_last=None, android_first=None, android_last=None, ios_first=None, ios_last=None, webview_first=None, webview_last=None): # noqa: E501
1818
"""CreateOriginTrialRequest - a model defined in OpenAPI
1919
2020
:param announcement_url: The announcement_url of this CreateOriginTrialRequest. # noqa: E501
@@ -55,6 +55,8 @@ def __init__(self, announcement_url=None, browser=None, ot_description=None, dis
5555
:type ot_display_name: FieldInfo
5656
:param ot_action_requested: The ot_action_requested of this CreateOriginTrialRequest. # noqa: E501
5757
:type ot_action_requested: FieldInfo
58+
:param ot_creation__bypass_file_checks: The ot_creation__bypass_file_checks of this CreateOriginTrialRequest. # noqa: E501
59+
:type ot_creation__bypass_file_checks: FieldInfo
5860
:param ot_documentation_url: The ot_documentation_url of this CreateOriginTrialRequest. # noqa: E501
5961
:type ot_documentation_url: FieldInfo
6062
:param ot_emails: The ot_emails of this CreateOriginTrialRequest. # noqa: E501
@@ -122,6 +124,7 @@ def __init__(self, announcement_url=None, browser=None, ot_description=None, dis
122124
'ot_chromium_trial_name': FieldInfo,
123125
'ot_display_name': FieldInfo,
124126
'ot_action_requested': FieldInfo,
127+
'ot_creation__bypass_file_checks': FieldInfo,
125128
'ot_documentation_url': FieldInfo,
126129
'ot_emails': FieldInfo,
127130
'ot_feedback_submission_url': FieldInfo,
@@ -167,6 +170,7 @@ def __init__(self, announcement_url=None, browser=None, ot_description=None, dis
167170
'ot_chromium_trial_name': 'ot_chromium_trial_name',
168171
'ot_display_name': 'ot_display_name',
169172
'ot_action_requested': 'ot_action_requested',
173+
'ot_creation__bypass_file_checks': 'ot_creation__bypass_file_checks',
170174
'ot_documentation_url': 'ot_documentation_url',
171175
'ot_emails': 'ot_emails',
172176
'ot_feedback_submission_url': 'ot_feedback_submission_url',
@@ -211,6 +215,7 @@ def __init__(self, announcement_url=None, browser=None, ot_description=None, dis
211215
self._ot_chromium_trial_name = ot_chromium_trial_name
212216
self._ot_display_name = ot_display_name
213217
self._ot_action_requested = ot_action_requested
218+
self._ot_creation__bypass_file_checks = ot_creation__bypass_file_checks
214219
self._ot_documentation_url = ot_documentation_url
215220
self._ot_emails = ot_emails
216221
self._ot_feedback_submission_url = ot_feedback_submission_url
@@ -645,6 +650,27 @@ def ot_action_requested(self, ot_action_requested: FieldInfo):
645650

646651
self._ot_action_requested = ot_action_requested
647652

653+
@property
654+
def ot_creation__bypass_file_checks(self) -> FieldInfo:
655+
"""Gets the ot_creation__bypass_file_checks of this CreateOriginTrialRequest.
656+
657+
658+
:return: The ot_creation__bypass_file_checks of this CreateOriginTrialRequest.
659+
:rtype: FieldInfo
660+
"""
661+
return self._ot_creation__bypass_file_checks
662+
663+
@ot_creation__bypass_file_checks.setter
664+
def ot_creation__bypass_file_checks(self, ot_creation__bypass_file_checks: FieldInfo):
665+
"""Sets the ot_creation__bypass_file_checks of this CreateOriginTrialRequest.
666+
667+
668+
:param ot_creation__bypass_file_checks: The ot_creation__bypass_file_checks of this CreateOriginTrialRequest.
669+
:type ot_creation__bypass_file_checks: FieldInfo
670+
"""
671+
672+
self._ot_creation__bypass_file_checks = ot_creation__bypass_file_checks
673+
648674
@property
649675
def ot_documentation_url(self) -> FieldInfo:
650676
"""Gets the ot_documentation_url of this CreateOriginTrialRequest.

gen/py/chromestatus_openapi/chromestatus_openapi/models/stage_field.py

Lines changed: 27 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ class StageField(Model):
1414
Do not edit the class manually.
1515
"""
1616

17-
def __init__(self, announcement_url=None, browser=None, ot_description=None, display_name=None, enterprise_policies=None, finch_url=None, experiment_goals=None, experiment_risks=None, experiment_extension_reason=None, intent_thread_url=None, origin_trial_feedback_url=None, origin_trial_id=None, ot_approval_buganizer_component=None, ot_approval_buganizer_custom_field_id=None, ot_approval_criteria_url=None, ot_approval_group_email=None, ot_chromium_trial_name=None, ot_display_name=None, ot_action_requested=None, ot_documentation_url=None, ot_emails=None, ot_feedback_submission_url=None, ot_has_third_party_support=None, ot_is_critical_trial=None, ot_is_deprecation_trial=None, ot_owner_email=None, ot_request_note=None, ot_require_approvals=None, ot_stage_id=None, ot_webfeature_use_counter=None, rollout_impact=None, rollout_milestone=None, rollout_platforms=None, rollout_details=None): # noqa: E501
17+
def __init__(self, announcement_url=None, browser=None, ot_description=None, display_name=None, enterprise_policies=None, finch_url=None, experiment_goals=None, experiment_risks=None, experiment_extension_reason=None, intent_thread_url=None, origin_trial_feedback_url=None, origin_trial_id=None, ot_approval_buganizer_component=None, ot_approval_buganizer_custom_field_id=None, ot_approval_criteria_url=None, ot_approval_group_email=None, ot_chromium_trial_name=None, ot_display_name=None, ot_action_requested=None, ot_creation__bypass_file_checks=None, ot_documentation_url=None, ot_emails=None, ot_feedback_submission_url=None, ot_has_third_party_support=None, ot_is_critical_trial=None, ot_is_deprecation_trial=None, ot_owner_email=None, ot_request_note=None, ot_require_approvals=None, ot_stage_id=None, ot_webfeature_use_counter=None, rollout_impact=None, rollout_milestone=None, rollout_platforms=None, rollout_details=None): # noqa: E501
1818
"""StageField - a model defined in OpenAPI
1919
2020
:param announcement_url: The announcement_url of this StageField. # noqa: E501
@@ -55,6 +55,8 @@ def __init__(self, announcement_url=None, browser=None, ot_description=None, dis
5555
:type ot_display_name: FieldInfo
5656
:param ot_action_requested: The ot_action_requested of this StageField. # noqa: E501
5757
:type ot_action_requested: FieldInfo
58+
:param ot_creation__bypass_file_checks: The ot_creation__bypass_file_checks of this StageField. # noqa: E501
59+
:type ot_creation__bypass_file_checks: FieldInfo
5860
:param ot_documentation_url: The ot_documentation_url of this StageField. # noqa: E501
5961
:type ot_documentation_url: FieldInfo
6062
:param ot_emails: The ot_emails of this StageField. # noqa: E501
@@ -106,6 +108,7 @@ def __init__(self, announcement_url=None, browser=None, ot_description=None, dis
106108
'ot_chromium_trial_name': FieldInfo,
107109
'ot_display_name': FieldInfo,
108110
'ot_action_requested': FieldInfo,
111+
'ot_creation__bypass_file_checks': FieldInfo,
109112
'ot_documentation_url': FieldInfo,
110113
'ot_emails': FieldInfo,
111114
'ot_feedback_submission_url': FieldInfo,
@@ -143,6 +146,7 @@ def __init__(self, announcement_url=None, browser=None, ot_description=None, dis
143146
'ot_chromium_trial_name': 'ot_chromium_trial_name',
144147
'ot_display_name': 'ot_display_name',
145148
'ot_action_requested': 'ot_action_requested',
149+
'ot_creation__bypass_file_checks': 'ot_creation__bypass_file_checks',
146150
'ot_documentation_url': 'ot_documentation_url',
147151
'ot_emails': 'ot_emails',
148152
'ot_feedback_submission_url': 'ot_feedback_submission_url',
@@ -179,6 +183,7 @@ def __init__(self, announcement_url=None, browser=None, ot_description=None, dis
179183
self._ot_chromium_trial_name = ot_chromium_trial_name
180184
self._ot_display_name = ot_display_name
181185
self._ot_action_requested = ot_action_requested
186+
self._ot_creation__bypass_file_checks = ot_creation__bypass_file_checks
182187
self._ot_documentation_url = ot_documentation_url
183188
self._ot_emails = ot_emails
184189
self._ot_feedback_submission_url = ot_feedback_submission_url
@@ -605,6 +610,27 @@ def ot_action_requested(self, ot_action_requested: FieldInfo):
605610

606611
self._ot_action_requested = ot_action_requested
607612

613+
@property
614+
def ot_creation__bypass_file_checks(self) -> FieldInfo:
615+
"""Gets the ot_creation__bypass_file_checks of this StageField.
616+
617+
618+
:return: The ot_creation__bypass_file_checks of this StageField.
619+
:rtype: FieldInfo
620+
"""
621+
return self._ot_creation__bypass_file_checks
622+
623+
@ot_creation__bypass_file_checks.setter
624+
def ot_creation__bypass_file_checks(self, ot_creation__bypass_file_checks: FieldInfo):
625+
"""Sets the ot_creation__bypass_file_checks of this StageField.
626+
627+
628+
:param ot_creation__bypass_file_checks: The ot_creation__bypass_file_checks of this StageField.
629+
:type ot_creation__bypass_file_checks: FieldInfo
630+
"""
631+
632+
self._ot_creation__bypass_file_checks = ot_creation__bypass_file_checks
633+
608634
@property
609635
def ot_documentation_url(self) -> FieldInfo:
610636
"""Gets the ot_documentation_url of this StageField.

gen/py/chromestatus_openapi/chromestatus_openapi/openapi/openapi.yaml

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2056,6 +2056,9 @@ components:
20562056
ot_display_name:
20572057
form_field_name: form_field_name
20582058
value: "{}"
2059+
ot_creation__bypass_file_checks:
2060+
form_field_name: form_field_name
2061+
value: "{}"
20592062
rollout_platforms:
20602063
form_field_name: form_field_name
20612064
value: "{}"
@@ -2218,6 +2221,8 @@ components:
22182221
$ref: '#/components/schemas/FieldInfo'
22192222
ot_action_requested:
22202223
$ref: '#/components/schemas/FieldInfo'
2224+
ot_creation__bypass_file_checks:
2225+
$ref: '#/components/schemas/FieldInfo'
22212226
ot_documentation_url:
22222227
$ref: '#/components/schemas/FieldInfo'
22232228
ot_emails:

0 commit comments

Comments
 (0)