Skip to content

chore: Validate envs and secrets during build time#29634

Open
Cal-L wants to merge 1 commit intomainfrom
chore/MCWP-564-validate-envs-and-secrets
Open

chore: Validate envs and secrets during build time#29634
Cal-L wants to merge 1 commit intomainfrom
chore/MCWP-564-validate-envs-and-secrets

Conversation

@Cal-L
Copy link
Copy Markdown
Contributor

@Cal-L Cal-L commented May 2, 2026

Description

This safeguard is a follow up to catch malformed envs and secrets during build time to prevent issues similar to incident 1578. If any issues are detected during build time, the Build Mobile App workflow will fail with a message listing the offending value

Changelog

CHANGELOG entry:

Related issues

Fixes: https://consensyssoftware.atlassian.net/browse/MCWP-564

Manual testing steps

Feature: my feature name

  Scenario: user [verb for user action]
    Given [describe expected initial app state]

    When user [verb for user action]
    Then [describe expected outcome]

Screenshots/Recordings

Before

After

Pre-merge author checklist

Performance checks (if applicable)

  • I've tested on Android
    • Ideally on a mid-range device; emulator is acceptable
  • I've tested with a power user scenario
    • Use these power-user SRPs to import wallets with many accounts and tokens
  • I've instrumented key operations with Sentry traces for production performance metrics

For performance guidelines and tooling, see the Performance Guide.

Pre-merge reviewer checklist

  • I've manually tested the PR (e.g. pull and build branch, run the app, test code being changed).
  • I confirm that this PR addresses all acceptance criteria described in the ticket it closes and includes the necessary testing evidence such as recordings and or screenshots.

Note

Cursor Bugbot is generating a summary for commit 3547f68. Configure here.

@github-actions
Copy link
Copy Markdown
Contributor

github-actions Bot commented May 2, 2026

CLA Signature Action: All authors have signed the CLA. You may need to manually re-run the blocking PR check if it doesn't pass in a few minutes.

@metamaskbotv2 metamaskbotv2 Bot added the team-mobile-platform Mobile Platform team label May 2, 2026
@github-actions github-actions Bot added the size-M label May 2, 2026
@github-actions
Copy link
Copy Markdown
Contributor

github-actions Bot commented May 2, 2026

🔍 Smart E2E Test Selection

  • Selected E2E tags: None (no tests recommended)
  • Selected Performance tags: None (no tests recommended)
  • Risk Level: low
  • AI Confidence: 98%
click to see 🤖 AI reasoning details

E2E Test Selection:
All 4 changed files are purely build/CI validation scripts in the scripts/ directory:

  1. scripts/lib/validate-value.js - New shared utility for hygiene-checking CI-injected values (secrets, env vars). Detects trailing whitespace, control chars, invisible Unicode, etc. Pure Node.js utility with no app code dependency.

  2. scripts/lib/validate-value.test.js - Unit tests for the above utility. Jest tests for the script, not Detox E2E tests.

  3. scripts/validate-build-config.js - Modified to use checkValue for validating builds.yml env entries. Build-time validation only.

  4. scripts/validate-secrets-from-config.js - Refactored to use checkValue for richer secret validation with GitHub Actions annotations. CI pre-build step only.

None of these changes touch:

  • App source code (no app/ directory changes)
  • E2E test infrastructure (no tests/ directory changes)
  • CI workflow files (no .github/workflows/ changes)
  • Any controllers, Engine, or UI components
  • Navigation, modals, or any user-facing flows

These are purely build-time CI validation scripts that run before the app is compiled. They have zero impact on app behavior, user flows, or E2E test execution. No E2E tests need to run to validate these changes — they are validated by their own unit tests (validate-value.test.js).

Performance Test Selection:
No performance-relevant changes. All modifications are to build/CI validation scripts with no impact on app rendering, data loading, state management, or any user-facing flows.

View GitHub Actions results

@Cal-L Cal-L added No QA Needed Apply this label when your PR does not need any QA effort. needs-dev-review PR needs reviews from other engineers (in order to receive required approvals) no-changelog no-changelog Indicates no external facing user changes, therefore no changelog documentation needed no changelog required No changelog entry is required for this change labels May 2, 2026
@github-project-automation github-project-automation Bot moved this to Needs dev review in PR review queue May 2, 2026
Copy link
Copy Markdown
Contributor

@cursor cursor Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Cursor Bugbot has reviewed your changes and found 1 potential issue.

Fix All in Cursor

❌ Bugbot Autofix is OFF. To automatically fix reported issues with cloud agents, have a team admin enable autofix in the Cursor dashboard.

Reviewed by Cursor Bugbot for commit 3547f68. Configure here.

}

const str = String(value);
const len = Buffer.byteLength(str, 'utf8');
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Offset messages mix character indices with byte lengths

Low Severity

len is computed via Buffer.byteLength(str, 'utf8') (byte count), but crIndex, nulIndex, ctrlMatch.index, and zwMatch.index are JavaScript string character indices. The error messages combine them as offset ${index}/${len}, presenting a character position alongside a byte total. For any non-ASCII content these are different units, making the diagnostic output misleading — e.g., a \r at character index 4 in "café\r" would read offset 4/6 because é is two bytes in UTF-8.

Additional Locations (2)
Fix in Cursor Fix in Web

Reviewed by Cursor Bugbot for commit 3547f68. Configure here.

@sonarqubecloud
Copy link
Copy Markdown

sonarqubecloud Bot commented May 2, 2026

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

needs-dev-review PR needs reviews from other engineers (in order to receive required approvals) no changelog required No changelog entry is required for this change No QA Needed Apply this label when your PR does not need any QA effort. no-changelog no-changelog Indicates no external facing user changes, therefore no changelog documentation needed size-M team-mobile-platform Mobile Platform team

Projects

Status: Needs dev review

Development

Successfully merging this pull request may close these issues.

1 participant