日常开发 bug 汇总记录

6 minute

前言

这里记录一些比较杂的 bug,持续更新中。下面是其他一些归类了的 bug 记录:

Java 开发中遇到的 bug 记录

Python 开发中遇到的 bug 记录

certbot renew 报错 urlib3 依赖问题

try:

1pip install --upgrade --force-reinstall 'requests==2.6.0' urllib3

I’ve had the same problem https://niuhp.com/other/https-certbot.html

mybatis 判断和语法错误

1<if test="employeeIds != null and employeeIds.size > 0">
2    AND A.EmployeeId in
3    <foreach collection="employeeIds" index="index" item="item" open="(" separator="," close=")">
4        #{item}
5    </foreach>
6</if>
7
8ORDER BY A.FeedId DESC

and employeeIds.size > 0 不可少否则报错:

1org.springframework.jdbc.BadSqlGrammarException

curl 请求路径正确但报 404

去掉 content-length 限制 -H 'Content-Length: 19'

sqlserver TLSv1 was negotiated. Please update server and client to use TLSv1.2 at minimum.

由于公司的 sqlserver 只支持 tls1 所以需要安装旧版本 driver 并配置 VM option:

1"-Djdk.tls.disabledAlgorithms=SSLv3, TLSv1.1, RC4, DES, MD5withRSA, DH keySize < 1024, EC keySize < 224, 3DES_EDE_CBC, anon, NULL"

driver 使用 8 及以下版本即可。

Unittest test discovery error for workspace

12024-02-05 15:27:34.532 [error]     from typing_extensions import Literal, NotRequired, TypedDict
2  File "/Users/zh/.vscode/extensions/ms-python.python-2024.0.0/pythonFiles/lib/python/typing_extensions.py", line 916
3    def TypedDict(typename, fields=_marker, /, *, total=True, **kwargs):
4                                            ^
5SyntaxError: invalid syntax
6
72024-02-05 15:27:34.544 [error] Subprocess exited unsuccessfully with exit code 1 and signal null on workspace /Users/zh/Codes/jvav. Creating and sending error discovery payload 
8
92024-02-05 15:27:34.544 [error] Unittest test discovery error for workspace:  /Users/zh/Codes/jvav 

Fixed by #21757:

Thank you for your issue report. We are looking into this now! In the meantime, you are likely on the new testing rewrite and this is why you saw a change in behavior. You can opt out of the rewrite as I get this fix in by setting this in your user settings: “python.experiments.optOutFrom”: [“pythonTestAdapter”],. If this doesn’t work let me know as this will mean it is a different issue. Thank you and I will send updates in this thread as I get a fix in.

1// settings.json
2"python.experiments.optOutFrom": ["pythonTestAdapter"]

Gitignore 失效

1git rm -rf --cached .
2git add .

Nginx 相对地址资源引用不走反向代理

1location /pay/usdt/ {
2  sub_filter 'src="/img/'  'src="/pay/usdt/img/';
3  sub_filter 'src="/js/' 'src="/pay/usdt/js/' ;
4  sub_filter 'src="/css/' 'src="/pay/usdt/css/' ;
5  sub_filter_once off;
6  
7  proxy_pass http://127.0.0.1:8080/;
8}

Nginx 无法加载 css

1http {
2    include /etc/nginx/mime.types;
3}

dujiaoka 重启后前台需要重新安装

1# enter dujiaoka container
2echo "ok" > /dujiaoka/install.lock

manpath: can’t set the locale; make sure $LC_* and $LANG are correct

Add these lines to /etc/environment:

1LANG=en_US.utf-8
2LC_ALL=en_US.utf-8

RSSHub commit 不通过

报错提示说缺少某个依赖(pinyin-pro),是文档相关的。

如果修改了文档,那么需要到 website 下运行 pnpm i 安装相关依赖,以便于 commit 检查。

InfluxDb 引号问题

插入数据时,tag 不带引号,field 字符串类型带双引号

查询数据时,字符串类型带单引号

docker-compose 容器内无法连接服务的问题

这是一个 docker-compose 配置文件:

 1version: "3"
 2
 3services:
 4  cache:
 5    image: redis
 6    command: bash -c "mkdir -p ${PATH_REDIS} && touch ${PATH_REDIS}/redis.conf && redis-server ${PATH_REDIS}/redis.conf"
 7    ports:
 8      - "6379:6379"
 9    volumes:
10      - ${HOST_PATH_ROOT}/redis:${PATH_REDIS}
11      - ${HOST_PATH_ROOT}/redis/data:/data
12  web:
13    build: .
14    volumes:
15      - ${HOST_PATH_ROOT}:${PATH_ROOT}
16    depends_on:
17      - cache
18    # network_mode: "host"

我组织了两个容器服务,redis 和 web,在 web 中需要连接到 redis,如果指定的 redis 地址为 127.0.0.1 则无法连接到,报错如下:

1ERROR: 无法连接到 redis 服务: 127.0.0.1:6379 : Error 111 connecting to 127.0.0.1:6379. Connection refused.

这是因为通过 docker-compose 组织的容器,主机名被设置为 cache 和 web,将 127.0.0.1 改为 cache 即可。

XX 不允许发送按键

执行发送按键的 applescript 时可能会失败:

1execution error: “System Events”遇到一个错误:“osascript”不允许发送按键。 (1002)

在隐私与安全性 -> 辅助功能 -> + -> 添加 /usr/bin/osascript 即可

.gitignore 反选的正确用法

排除 /.xxx 下除了 jvm.cfg 的所有文件:

1/.xxx/*
2!/.xxx/jvm.cfg

如果 /.xxx/* 写为 /.xxx/ 或 /.xxx 都将失效,因为这样忽略的是 ./xxx 这个文件夹,而不是整个文件夹下的文件,导致反选无效。

brew 安装报错 curl: (56) Failure when receiving data from the peer

1git config --global http.sslVerify "false"
2git config --global https.sslVerify "false"

oh-my-zsh agnoster 主题乱码问题

从这个链接下载字体文件: https://github.com/lxbrtsch/Menlo-for-Powerline

1mv "Menlo for Powerline.ttf" ~/Library/Fonts

VSCode -> Terminal Font Family 设置字体为 Menlo for Powerline

Terminal -> 设置 -> 字体 -> 更改

docker-compose volume 指定对象为文件时产生的问题

如果指定为文件(命名为 a),且事先没有创建该文件,那么当启动后,docker 将会自动创建一个名为 a 的目录。

这样就读取不到该文件了。

所以,如果指定的对象为文件,建议先创建。

Sqlite3 执行 sql 出错

1sqlite> select * from t_record where comment != "";
2Parse error: no such column:
3  select * from t_record where comment != "";
4                            error here ---^

应该将双引号改为单引号。

根据 SQL 标准,通常在标识符(例如表名或列名)周围使用双引号,而在字符串字面量周围使用单引号。

在 3.41 版本往后 cli 默认禁用了双引号表示字符串,使用单引号就不报错了:https://www.sqlite.org/quirks.html#double_quoted_string_literals_are_accepted

iterm2 无法使用 scp

1# server side
2vim .zprofile
3export iterm2_hostname=your_server_global_ip
4# then relogin