XIU2/CloudflareSpeedTest · error

[错误] 缺少配置项 [DNS_RECORDS_ID] !

Error message

[错误] 缺少配置项 [DNS_RECORDS_ID] !

What it means

_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.

Source

Thrown at script/cfst_ddns.sh:19

#!/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 的运行参数
	./cfst -o "result_ddns.txt"

View on GitHub (pinned to 1da0c025d7)

Solutions

  1. 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
  2. Set it in cfst_ddns.conf: DNS_RECORDS_ID=<record-id>
  3. Check the line is uncommented with a non-empty value after '='
  4. Re-run; remaining missing keys surface one at a time

Example fix

# cfst_ddns.conf (before)
DNS_RECORDS_ID=
# (after)
DNS_RECORDS_ID=372e67954025e0ba6aaa6d586b6e3ae5
Defensive patterns

Strategy: validation

Validate before calling

rid=$(grep '^DNS_RECORDS_ID=' cfst_ddns.conf | head -1 | cut -d= -f2-)
[[ $rid =~ ^[0-9a-f]{32}$ ]] || { echo 'DNS_RECORDS_ID malformed/empty' >&2; exit 1; }

Type guard

is_record_id(){ [[ $1 =~ ^[0-9a-f]{32}$ ]]; }

Prevention

When it happens

Trigger: cfst_ddns.conf exists but the DNS_RECORDS_ID= line is missing, commented out, or empty after '='.

Common situations: 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.

Related errors


AI-assisted analysis of XIU2/CloudflareSpeedTest@1da0c025d7 (2026-08-15). Data as JSON: /api/errors/a85827239d8d85b3. Report an issue: GitHub.