{"record":{"id":"96c107ae7e719975","repo":"XIU2/CloudflareSpeedTest","slug":"ttl","errorCode":null,"errorMessage":"[错误] 缺少配置项 [TTL] !","messagePattern":"\\[错误\\] 缺少配置项 \\[TTL\\] !","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"script/cfst_ddns.sh","lineNumber":29,"sourceCode":"_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\n\t# 判断结果文件是否存在，如果不存在说明结果为 0\n\t[[ ! -e \"result_ddns.txt\" ]] && echo \"CFST 测速结果 IP 数量为 0，跳过下面步骤...\" && exit 0\n\n\tCONTENT=$(sed -n \"2,1p\" result_ddns.txt | awk -F, '{print $1}')\n\tif [[ -z \"${CONTENT}\" ]]; then\n\t\techo \"CFST 测速结果 IP 数量为 0，跳过下面步骤...\"\n\t\texit 0\n\tfi\n\t# 如果 EMAIL 变量是空的，那么就代表要使用 API 令牌方式\n\tif [[ -n \"${EMAIL}\" ]]; then","sourceCodeStart":11,"sourceCodeEnd":47,"githubUrl":"https://github.com/XIU2/CloudflareSpeedTest/blob/1da0c025d7b6f9bf0b2b0cf47a547f65430deab2/script/cfst_ddns.sh#L11-L47","documentation":"_READ() requires TTL from cfst_ddns.conf (grep 'TTL=' | awk -F '=' '{print $NF}') and exits 1 at script/cfst_ddns.sh:29 when empty. TTL is embedded unquoted and unvalidated into the JSON payload — \"ttl\":${TTL} (lines 53/59) — so it must be a bare integer Cloudflare accepts: 1 (automatic) or 60-86400.","triggerScenarios":"cfst_ddns.conf has no TTL= line, a commented line, or 'TTL=' with an empty value.","commonSituations":"Blank template value; user enters a unit like '1h' or the word 'auto' which later makes the PUT return 400 invalid_ttl even though this check passed; user copies TTL from the dashboard (which displays 'Auto') instead of the numeric API value.","solutions":["Set TTL=1 (Cloudflare automatic TTL) or an integer between 60 and 86400 in cfst_ddns.conf","Do not quote or suffix the value — it is spliced raw into the JSON number position","Re-run the script to finish the _READ checks"],"exampleFix":"# cfst_ddns.conf (before)\nTTL=\n# (after)\nTTL=1","handlingStrategy":"validation","validationCode":"ttl=$(grep '^TTL=' cfst_ddns.conf | head -1 | cut -d= -f2-)\n[[ $ttl =~ ^(1|[6-9][0-9]|[1-9][0-9]{2,3}|86400)$ ]] || { echo \"TTL invalid: '$ttl' (use 1 or 60-86400)\" >&2; exit 1; }","typeGuard":"is_valid_ttl(){ [ \"$1\" -eq \"$1\" ] 2>/dev/null && { [ \"$1\" -eq 1 ] || { [ \"$1\" -ge 60 ] && [ \"$1\" -le 86400 ]; }; }; }","tryCatchPattern":null,"preventionTips":["Use TTL=1 (auto) unless you specifically need a fixed TTL","The value is spliced unquoted into JSON — never add quotes, units, or spaces","Re-check TTL after copying dashboard values, which display 'Auto' instead of 1"],"tags":["shell","bash","cloudflare","ddns","configuration","dns"],"backgroundTag":null,"analyzedSha":"1da0c025d7b6f9bf0b2b0cf47a547f65430deab2","analyzedAt":"2026-08-15T22:22:10.737Z","schemaVersion":2},"datasetVersion":"2026-08-16T03:17:38.424Z"}