XIU2/CloudflareSpeedTest · error
[错误] 缺少配置项 [ZONE_ID] !
Error message
[错误] 缺少配置项 [ZONE_ID] !
What it means
_READ() extracts ZONE_ID from cfst_ddns.conf via grep 'ZONE_ID=' | awk -F '=' '{print $NF}'; an empty result aborts with exit 1 at script/cfst_ddns.sh:17. ZONE_ID is the Cloudflare zone (domain) identifier later interpolated into the PUT URL https://api.cloudflare.com/client/v4/zones/${ZONE_ID}/dns_records/${DNS_RECORDS_ID} (lines 49/56), so the script refuses to continue without it.
Source
Thrown at script/cfst_ddns.sh:17
#!/usr/bin/env bash
PATH=/bin:/sbin:/usr/bin:/usr/sbin:/usr/local/bin:/usr/local/sbin:~/bin
export PATH
# --------------------------------------------------------------
# 项目: CloudflareSpeedTest 自动更新域名解析记录
# 版本: 1.0.5
# 作者: XIU2
# 项目: https://github.com/XIU2/CloudflareSpeedTest
# --------------------------------------------------------------
_READ() {
[[ ! -e "cfst_ddns.conf" ]] && echo -e "[错误] 配置文件不存在 [cfst_ddns.conf] !" && exit 1
CONFIG=$(cat "cfst_ddns.conf")
FOLDER=$(echo "${CONFIG}"|grep 'FOLDER='|awk -F '=' '{print $NF}')
[[ -z "${FOLDER}" ]] && echo -e "[错误] 缺少配置项 [FOLDER] !" && exit 1
ZONE_ID=$(echo "${CONFIG}"|grep 'ZONE_ID='|awk -F '=' '{print $NF}')
[[ -z "${ZONE_ID}" ]] && echo -e "[错误] 缺少配置项 [ZONE_ID] !" && exit 1
DNS_RECORDS_ID=$(echo "${CONFIG}"|grep 'DNS_RECORDS_ID='|awk -F '=' '{print $NF}')
[[ -z "${DNS_RECORDS_ID}" ]] && echo -e "[错误] 缺少配置项 [DNS_RECORDS_ID] !" && exit 1
KEY=$(echo "${CONFIG}"|grep 'KEY='|awk -F '=' '{print $NF}')
[[ -z "${KEY}" ]] && echo -e "[错误] 缺少配置项 [KEY] !" && exit 1
EMAIL=$(echo "${CONFIG}"|grep 'EMAIL='|awk -F '=' '{print $NF}')
[[ -z "${EMAIL}" ]] && echo -e "[信息] 缺少配置项 [EMAIL],由 [API 密钥] 方式转为 [API 令牌] 方式!"
TYPE=$(echo "${CONFIG}"|grep 'TYPE='|awk -F '=' '{print $NF}')
[[ -z "${TYPE}" ]] && echo -e "[错误] 缺少配置项 [TYPE] !" && exit 1
NAME=$(echo "${CONFIG}"|grep 'NAME='|awk -F '=' '{print $NF}')
[[ -z "${NAME}" ]] && echo -e "[错误] 缺少配置项 [NAME] !" && exit 1
TTL=$(echo "${CONFIG}"|grep 'TTL='|awk -F '=' '{print $NF}')
[[ -z "${TTL}" ]] && echo -e "[错误] 缺少配置项 [TTL] !" && exit 1
PROXIED=$(echo "${CONFIG}"|grep 'PROXIED='|awk -F '=' '{print $NF}')
[[ -z "${PROXIED}" ]] && echo -e "[错误] 缺少配置项 [PROXIED] !" && exit 1
}
_UPDATE() {
# 这里可以自己添加、修改 CFST 的运行参数View on GitHub (pinned to 1da0c025d7)
Solutions
- Get the 32-character Zone ID from the Cloudflare dashboard (domain Overview page, right-hand API section) or via GET /client/v4/zones?name=example.com
- Set it in cfst_ddns.conf: ZONE_ID=<32-hex-characters>
- Verify no leading '#', no spaces around '=', and exactly one ZONE_ID= line
- Re-run the script to confirm _READ proceeds to the next missing-key check
Example fix
# cfst_ddns.conf (before) ZONE_ID= # (after) ZONE_ID=023e105f4ecef8ad9ca31a8372d0c358a
Defensive patterns
Strategy: validation
Validate before calling
zid=$(grep '^ZONE_ID=' cfst_ddns.conf | head -1 | cut -d= -f2-)
[[ $zid =~ ^[0-9a-f]{32}$ ]] || { echo "ZONE_ID malformed: '${zid}'" >&2; exit 1; } Type guard
is_zone_id(){ [[ $1 =~ ^[0-9a-f]{32}$ ]]; } Prevention
- Fetch the Zone ID programmatically (GET /client/v4/zones?name=...) instead of hand-copying 32 hex chars
- Validate the 32-hex shape of ZONE_ID in a preflight before adding the job to cron
- Keep a filled example conf with fake-but-well-formed values as a template
When it happens
Trigger: cfst_ddns.conf is present but has no ZONE_ID= line, a commented-out line, or 'ZONE_ID=' with an empty value; duplicated keys where every match is empty also trigger it.
Common situations: User has not looked up the zone ID in the Cloudflare dashboard (domain Overview -> API section); the conf was hand-copied and the line dropped; user confused ZONE_ID with the account ID or with DNS_RECORDS_ID.
Related errors
- [错误] 缺少配置项 [DNS_RECORDS_ID] !
- [错误] 缺少配置项 [FOLDER] !
- [错误] 缺少配置项 [KEY] !
- [信息] 缺少配置项 [EMAIL],由 [API 密钥] 方式转为 [API 令牌] 方式!
- [错误] 缺少配置项 [TYPE] !
AI-assisted analysis of XIU2/CloudflareSpeedTest@1da0c025d7 (2026-08-15).
Data as JSON: /api/errors/6b5e6cad1aa5476a.
Report an issue: GitHub.