Skip to main content

Pre-deploy Validation (tcb validate)

Version Requirement

tcb validate is available since v3.8.0.

tcb validate checks whether the project's cloudbaserc.json (v2.1) config is valid, resource directories exist, and resource references are consistent — catching problems early before deployment. It is the companion command to Declarative Deployment (tcb deploy).

Quick Start

# Validate cloudbaserc.json in the current directory
tcb validate

# Specify a config file
tcb validate --config-file ./config/prod.json

# Validate a specific mode (applies envOverrides)
tcb validate --mode dev

On success, it prints a resource overview and exits with code 0:

Config version: 2.1
Resource overview: 1 cloud function, 1 static hosting, 0 databases, 2 gateway routes

Validation Items

ItemDescriptionExample
Schema versionConfig conforms to v2.1 Schema (valid fields, no extra properties)gateway.routes rejects unknown fields like cdnType
envIdConfig must include envId-
requiredEnvRequired env vars declared in requiredEnv are provided-
Resource directoriesFunction dirs / hosting roots existfunctions/pay-common/ missing is an error
ConsistencyGateway target references exist in configtarget: "function:pay-common" but the function is not defined

Output and Exit Codes

CaseOutputExit code
ValidConfig version + resource overview0
InvalidError list (field + fix suggestion)1
Errors (2)
- gateway.routes.0: config does not conform to v2.1 Schema: should NOT have additional properties
Fix: check the gateway.routes.0 field
- gateway.routes.1: config does not conform to v2.1 Schema: should NOT have additional properties
Fix: check the gateway.routes.1 field

Relationship with tcb deploy

  • tcb deploy also performs a lightweight config guard (envId presence, valid config)
  • It is recommended to run tcb validate before tcb deploy in CI to surface config issues early
  • Full validation (Schema/dirs/consistency) is authoritative in tcb validate

References