XIU2/CloudflareSpeedTest · error
[错误] 缺少配置项 [TYPE] !
Error message
[错误] 缺少配置项 [TYPE] !
What it means
_READ() requires TYPE from cfst_ddns.conf (grep 'TYPE=' | awk -F '=' '{print $NF}') and exits 1 at script/cfst_ddns.sh:25 when empty. TYPE is injected unquoted into the JSON payload — "type":"${TYPE}" (lines 53/59) — and must match the DNS record being updated (typically A for IPv4 results, AAAA for IPv6).
Source
Thrown at script/cfst_ddns.sh:25
# 作者: 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"
# 判断结果文件是否存在,如果不存在说明结果为 0
[[ ! -e "result_ddns.txt" ]] && echo "CFST 测速结果 IP 数量为 0,跳过下面步骤..." && exit 0
CONTENT=$(sed -n "2,1p" result_ddns.txt | awk -F, '{print $1}')
if [[ -z "${CONTENT}" ]]; then
echo "CFST 测速结果 IP 数量为 0,跳过下面步骤..."View on GitHub (pinned to 1da0c025d7)
Solutions
- Set TYPE=A in cfst_ddns.conf (cfst_ddns.sh tests IPv4 with ./cfst and reads the first result IP)
- Use TYPE=AAAA only if you changed _UPDATE to run cfst with -f ipv6.txt
- Ensure the value exactly matches the existing record's type in Cloudflare, with no spaces or quotes
- Re-run to clear the remaining _READ checks
Example fix
# cfst_ddns.conf (before) TYPE= # (after) TYPE=A
Defensive patterns
Strategy: validation
Validate before calling
type=$(grep '^TYPE=' cfst_ddns.conf | head -1 | cut -d= -f2-)
[[ $type == A || $type == AAAA || $type == CNAME ]] || { echo "TYPE invalid: '$type'" >&2; exit 1; } Type guard
is_dns_type(){ case $1 in A|AAAA|CNAME) return 0;; *) return 1;; esac; } Prevention
- Use the literal DNS record type (A/AAAA), never 'ipv4'/'ipv6'
- Match TYPE to the record already stored under DNS_RECORDS_ID — Cloudflare rejects type mismatches on PUT
- If you switch the record between A and AAAA, update TYPE and re-fetch the record id in the same change
When it happens
Trigger: cfst_ddns.conf has no TYPE= line, a commented line, or 'TYPE=' with nothing after the '='.
Common situations: Template line left blank during initial setup; user set an arbitrary value like 'ipv4' instead of the DNS record type 'A'/'AAAA'; wrong case or stray whitespace breaks the later PUT even when this check passes.
Related errors
- [错误] 缺少配置项 [NAME] !
- [错误] 缺少配置项 [TTL] !
- [错误] 缺少配置项 [PROXIED] !
- [错误] 缺少配置项 [FOLDER] !
- [错误] 缺少配置项 [ZONE_ID] !
AI-assisted analysis of XIU2/CloudflareSpeedTest@1da0c025d7 (2026-08-15).
Data as JSON: /api/errors/19bbd9125f35097f.
Report an issue: GitHub.