Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

错误提示 #714

Open
Khaose-tech opened this issue Jan 14, 2025 · 4 comments
Open

错误提示 #714

Khaose-tech opened this issue Jan 14, 2025 · 4 comments

Comments

@Khaose-tech
Copy link

现在跑脚本会出现两个错误提示
1:jq: error (at :1): Cannot iterate over null (null)
2:Error: Malformed UTF-8 data

第一个不会影响脚本运行
第二个就会直接结束脚本

不知各位大佬有办法解决

@6dylan6
Copy link
Owner

6dylan6 commented Jan 14, 2025

@Khaose-tech 配置管理taskbefore.sh看看有没有内容,有就清空掉

@Khaose-tech
Copy link
Author

感谢大佬的回复,清除task_before.sh里的内容,“jq: error (at :1): Cannot iterate over null (null)”这个问题已经解决了

@Khaose-tech
Copy link
Author

第二个错误终于解决了。
青龙面板从2.18.0升级到2.18.1,就会出现这个错误。
只能先备份数据,再重装青龙面板,就可以了。

@fantasyroot
Copy link

fantasyroot commented Jan 31, 2025

@6dylan6 jq: error (at :1): Cannot iterate over null (null) 这个报错我排查定位出现在 task_before.sh( https://github.com/6dylan6/jdpro/blob/main/docker/task_before.sh ) ,建议修改一下其中的 def_envs_tool 函数为如下:

def_envs_tool(){
    local i
    for i in $@; do
        # 检查文件是否存在
        if [[ ! -f "$file_auth_user" ]]; then
            echo "ERROR: auth 文件不存在: $file_auth_user"
            return 1
        fi
        
        # 获取并验证 token
        local token=$(cat $file_auth_user | jq -r .token 2>/dev/null)
        if [[ -z "${token}" || "${token}" == "null" ]]; then
            echo "ERROR: token 无效"
            return 1
        fi
        
        # 发送请求并处理响应
        local response=$(curl -s --noproxy "*" "http://0.0.0.0:5600/api/envs?searchValue=$i" -H "Authorization: Bearer $token")
        if [[ $? -ne 0 ]]; then
            echo "ERROR: API 请求失败"
            continue
        fi
        
        # 安全地解析 JSON
        if echo "${response}" | jq -e . >/dev/null 2>&1; then
            echo "${response}" | jq '.data // empty'
        else
            echo "ERROR: 无效的 JSON 响应"
        fi
    done
}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants