{"record":{"id":"a85827239d8d85b3","repo":"XIU2/CloudflareSpeedTest","slug":"dns-records-id","errorCode":null,"errorMessage":"[错误] 缺少配置项 [DNS_RECORDS_ID] !","messagePattern":"\\[错误\\] 缺少配置项 \\[DNS_RECORDS_ID\\] !","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"script/cfst_ddns.sh","lineNumber":19,"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 的运行参数\n\t./cfst -o \"result_ddns.txt\"\n","sourceCodeStart":1,"sourceCodeEnd":37,"githubUrl":"https://github.com/XIU2/CloudflareSpeedTest/blob/1da0c025d7b6f9bf0b2b0cf47a547f65430deab2/script/cfst_ddns.sh#L1-L37","documentation":"_READ() reads DNS_RECORDS_ID from cfst_ddns.conf (grep 'DNS_RECORDS_ID=' | awk -F '=' '{print $NF}') and exits 1 at script/cfst_ddns.sh:19 when it is empty. This is the ID of the exact DNS record the script PUTs to at lines 49/56; without it the record cannot be updated, so the script refuses to start.","triggerScenarios":"cfst_ddns.conf exists but the DNS_RECORDS_ID= line is missing, commented out, or empty after '='.","commonSituations":"User filled ZONE_ID but has not listed their DNS records to get the record ID; the record was deleted and recreated in Cloudflare (new ID); a partially copied conf template.","solutions":["List records and copy the id of the record to update: curl -H \"Authorization: Bearer <token>\" https://api.cloudflare.com/client/v4/zones/<ZONE_ID>/dns_records and read .result[].id","Set it in cfst_ddns.conf: DNS_RECORDS_ID=<record-id>","Check the line is uncommented with a non-empty value after '='","Re-run; remaining missing keys surface one at a time"],"exampleFix":"# cfst_ddns.conf (before)\nDNS_RECORDS_ID=\n# (after)\nDNS_RECORDS_ID=372e67954025e0ba6aaa6d586b6e3ae5","handlingStrategy":"validation","validationCode":"rid=$(grep '^DNS_RECORDS_ID=' cfst_ddns.conf | head -1 | cut -d= -f2-)\n[[ $rid =~ ^[0-9a-f]{32}$ ]] || { echo 'DNS_RECORDS_ID malformed/empty' >&2; exit 1; }","typeGuard":"is_record_id(){ [[ $1 =~ ^[0-9a-f]{32}$ ]]; }","tryCatchPattern":null,"preventionTips":["Query the record id right before generating the conf: curl .../zones/$ZONE_ID/dns_records | jq -r '.result[] | \"\\(.type) \\(.name) \\(.id)\"'","Re-fetch DNS_RECORDS_ID whenever the record is deleted/recreated in the dashboard","Store zone/record ids adjacent in the conf so they are regenerated as a pair"],"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"}