{"record":{"id":"6b5e6cad1aa5476a","repo":"XIU2/CloudflareSpeedTest","slug":"zone-id","errorCode":null,"errorMessage":"[错误] 缺少配置项 [ZONE_ID] !","messagePattern":"\\[错误\\] 缺少配置项 \\[ZONE_ID\\] !","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"script/cfst_ddns.sh","lineNumber":17,"sourceCode":"#!/usr/bin/env bash\nPATH=/bin:/sbin:/usr/bin:/usr/sbin:/usr/local/bin:/usr/local/sbin:~/bin\nexport PATH\n# --------------------------------------------------------------\n#\t项目: CloudflareSpeedTest 自动更新域名解析记录\n#\t版本: 1.0.5\n#\t作者: XIU2\n#\t项目: https://github.com/XIU2/CloudflareSpeedTest\n# --------------------------------------------------------------\n\n_READ() {\n\t[[ ! -e \"cfst_ddns.conf\" ]] && echo -e \"[错误] 配置文件不存在 [cfst_ddns.conf] !\" && exit 1\n\tCONFIG=$(cat \"cfst_ddns.conf\")\n\tFOLDER=$(echo \"${CONFIG}\"|grep 'FOLDER='|awk -F '=' '{print $NF}')\n\t[[ -z \"${FOLDER}\" ]] && echo -e \"[错误] 缺少配置项 [FOLDER] !\" && exit 1\n\tZONE_ID=$(echo \"${CONFIG}\"|grep 'ZONE_ID='|awk -F '=' '{print $NF}')\n\t[[ -z \"${ZONE_ID}\" ]] && echo -e \"[错误] 缺少配置项 [ZONE_ID] !\" && exit 1\n\tDNS_RECORDS_ID=$(echo \"${CONFIG}\"|grep 'DNS_RECORDS_ID='|awk -F '=' '{print $NF}')\n\t[[ -z \"${DNS_RECORDS_ID}\" ]] && echo -e \"[错误] 缺少配置项 [DNS_RECORDS_ID] !\" && exit 1\n\tKEY=$(echo \"${CONFIG}\"|grep 'KEY='|awk -F '=' '{print $NF}')\n\t[[ -z \"${KEY}\" ]] && echo -e \"[错误] 缺少配置项 [KEY] !\" && exit 1\n\tEMAIL=$(echo \"${CONFIG}\"|grep 'EMAIL='|awk -F '=' '{print $NF}')\n\t[[ -z \"${EMAIL}\" ]] && echo -e \"[信息] 缺少配置项 [EMAIL]，由 [API 密钥] 方式转为 [API 令牌] 方式!\"\n\tTYPE=$(echo \"${CONFIG}\"|grep 'TYPE='|awk -F '=' '{print $NF}')\n\t[[ -z \"${TYPE}\" ]] && echo -e \"[错误] 缺少配置项 [TYPE] !\" && exit 1\n\tNAME=$(echo \"${CONFIG}\"|grep 'NAME='|awk -F '=' '{print $NF}')\n\t[[ -z \"${NAME}\" ]] && echo -e \"[错误] 缺少配置项 [NAME] !\" && exit 1\n\tTTL=$(echo \"${CONFIG}\"|grep 'TTL='|awk -F '=' '{print $NF}')\n\t[[ -z \"${TTL}\" ]] && echo -e \"[错误] 缺少配置项 [TTL] !\" && exit 1\n\tPROXIED=$(echo \"${CONFIG}\"|grep 'PROXIED='|awk -F '=' '{print $NF}')\n\t[[ -z \"${PROXIED}\" ]] && echo -e \"[错误] 缺少配置项 [PROXIED] !\" && exit 1\n}\n\n_UPDATE() {\n\t# 这里可以自己添加、修改 CFST 的运行参数","sourceCodeStart":1,"sourceCodeEnd":35,"githubUrl":"https://github.com/XIU2/CloudflareSpeedTest/blob/1da0c025d7b6f9bf0b2b0cf47a547f65430deab2/script/cfst_ddns.sh#L1-L35","documentation":"_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.","triggerScenarios":"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.","commonSituations":"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.","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"],"exampleFix":"# cfst_ddns.conf (before)\nZONE_ID=\n# (after)\nZONE_ID=023e105f4ecef8ad9ca31a8372d0c358a","handlingStrategy":"validation","validationCode":"zid=$(grep '^ZONE_ID=' cfst_ddns.conf | head -1 | cut -d= -f2-)\n[[ $zid =~ ^[0-9a-f]{32}$ ]] || { echo \"ZONE_ID malformed: '${zid}'\" >&2; exit 1; }","typeGuard":"is_zone_id(){ [[ $1 =~ ^[0-9a-f]{32}$ ]]; }","tryCatchPattern":null,"preventionTips":["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"],"tags":["shell","bash","cloudflare","ddns","configuration","api"],"backgroundTag":null,"analyzedSha":"1da0c025d7b6f9bf0b2b0cf47a547f65430deab2","analyzedAt":"2026-08-15T22:22:10.737Z","schemaVersion":2},"datasetVersion":"2026-08-16T03:17:38.424Z"}