2025-09-05 15:19:24,600 - manual_migration - INFO - 开始手动添加 location_type 字段...
2025-09-05 15:19:24,601 - manual_migration - INFO - 开始添加 location_type 字段...
2025-09-05 15:19:24,633 - manual_migration - INFO - 正在添加 location_type 字段...
2025-09-05 15:19:24,670 - manual_migration - INFO - ✅ location_type 字段添加成功
2025-09-05 15:19:24,670 - manual_migration - INFO - 正在为现有记录设置默认值...
2025-09-05 15:19:24,670 - manual_migration - INFO - ✅ 已为 0 条记录设置为物理库位（location_type = 1）
2025-09-05 15:19:24,671 - manual_migration - INFO - 验证结果：总记录数 32，物理库位 32，逻辑库位 0
2025-09-05 15:19:24,671 - manual_migration - INFO - 🎉 location_type 字段添加完成！
2025-09-05 15:19:24,671 - manual_migration - INFO - 显示更新后的表结构：
2025-09-05 15:19:24,673 - manual_migration - INFO - vwed_operate_point_layer 表结构：
2025-09-05 15:19:24,673 - manual_migration - INFO - Field		Type		Null	Key	Default	Extra
2025-09-05 15:19:24,673 - manual_migration - INFO - --------------------------------------------------------------------------------
2025-09-05 15:19:24,673 - manual_migration - INFO - id		char(64)		NO	PRI	None	
2025-09-05 15:19:24,673 - manual_migration - INFO - operate_point_id		char(64)		NO	MUL	None	
2025-09-05 15:19:24,673 - manual_migration - INFO - station_name		varchar(64)		NO		None	
2025-09-05 15:19:24,673 - manual_migration - INFO - area_name		varchar(64)		YES		None	
2025-09-05 15:19:24,673 - manual_migration - INFO - scene_id		varchar(64)		NO		None	
2025-09-05 15:19:24,673 - manual_migration - INFO - layer_index		int		NO		None	
2025-09-05 15:19:24,673 - manual_migration - INFO - layer_name		varchar(64)		YES		None	
2025-09-05 15:19:24,673 - manual_migration - INFO - is_occupied		tinyint(1)		NO		None	
2025-09-05 15:19:24,673 - manual_migration - INFO - goods_content		varchar(100)		NO		None	
2025-09-05 15:19:24,673 - manual_migration - INFO - goods_weight		int		YES		None	
2025-09-05 15:19:24,673 - manual_migration - INFO - goods_volume		int		YES		None	
2025-09-05 15:19:24,673 - manual_migration - INFO - is_locked		tinyint(1)		NO		None	
2025-09-05 15:19:24,673 - manual_migration - INFO - is_disabled		tinyint(1)		NO		None	
2025-09-05 15:19:24,673 - manual_migration - INFO - is_empty_tray		tinyint(1)		NO		None	
2025-09-05 15:19:24,673 - manual_migration - INFO - locked_by		varchar(128)		YES		None	
2025-09-05 15:19:24,673 - manual_migration - INFO - tags		varchar(255)		YES		None	
2025-09-05 15:19:24,673 - manual_migration - INFO - max_weight		int		YES		None	
2025-09-05 15:19:24,673 - manual_migration - INFO - max_volume		int		YES		None	
2025-09-05 15:19:24,673 - manual_migration - INFO - layer_height		int		YES		None	
2025-09-05 15:19:24,673 - manual_migration - INFO - goods_stored_at		datetime		YES		None	
2025-09-05 15:19:24,673 - manual_migration - INFO - goods_retrieved_at		datetime		YES		None	
2025-09-05 15:19:24,673 - manual_migration - INFO - last_access_at		datetime		YES		None	
2025-09-05 15:19:24,673 - manual_migration - INFO - description		text		YES		None	
2025-09-05 15:19:24,673 - manual_migration - INFO - config_json		text		YES		None	
2025-09-05 15:19:24,673 - manual_migration - INFO - created_at		datetime(6)		YES		None	
2025-09-05 15:19:24,673 - manual_migration - INFO - updated_at		datetime(6)		YES		None	
2025-09-05 15:19:24,673 - manual_migration - INFO - is_deleted		tinyint(1)		YES		None	
2025-09-05 15:19:24,673 - manual_migration - INFO - location_type		int		NO		1	
2025-09-05 15:19:24,674 - manual_migration - INFO - ✅ 迁移成功完成！
2025-09-11 19:35:47,683 - migration - INFO - 开始执行数据库自动迁移...
2025-09-11 19:35:47,683 - utils.db_migration - INFO - 开始数据库迁移
2025-09-11 19:35:47,732 - utils.db_migration - INFO - 发现 23 个模型
2025-09-11 19:35:47,751 - utils.db_migration - INFO - 表 vwed_script_api_registration 不存在，准备创建
2025-09-11 19:35:47,753 - utils.db_migration - ERROR - [logger.py:235] - error() - 创建表 vwed_script_api_registration 失败: (pymysql.err.OperationalError) (1824, "Failed to open the referenced table 'vwed_script_file'")
[SQL: 
CREATE TABLE vwed_script_api_registration (
	id INTEGER NOT NULL COMMENT '注册记录ID' AUTO_INCREMENT, 
	script_id VARCHAR(255) NOT NULL COMMENT '脚本实例ID', 
	file_id INTEGER NOT NULL COMMENT '脚本文件ID', 
	route_path VARCHAR(500) NOT NULL COMMENT '路由路径', 
	http_method VARCHAR(20) NOT NULL COMMENT 'HTTP方法: GET, POST, PUT, DELETE等', 
	handler_name VARCHAR(255) NOT NULL COMMENT '处理函数名', 
	description TEXT COMMENT '接口描述', 
	parameters JSON COMMENT '接口参数定义', 
	response_schema JSON COMMENT '响应格式定义', 
	is_active BOOL COMMENT '是否激活', 
	call_count INTEGER COMMENT '调用次数', 
	last_called_at DATETIME COMMENT '最后调用时间', 
	average_response_time_ms INTEGER COMMENT '平均响应时间(毫秒)', 
	created_at DATETIME NOT NULL COMMENT '注册时间', 
	PRIMARY KEY (id), 
	FOREIGN KEY(file_id) REFERENCES vwed_script_file (id)
)

]
(Background on this error at: https://sqlalche.me/e/20/e3q8)
Traceback (most recent call last):
  File "D:\Users\j2538\miniconda3\envs\pytf\Lib\site-packages\sqlalchemy\engine\base.py", line 1964, in _exec_single_context
    self.dialect.do_execute(
  File "D:\Users\j2538\miniconda3\envs\pytf\Lib\site-packages\sqlalchemy\engine\default.py", line 942, in do_execute
    cursor.execute(statement, parameters)
  File "D:\Users\j2538\miniconda3\envs\pytf\Lib\site-packages\pymysql\cursors.py", line 153, in execute
    result = self._query(query)
             ^^^^^^^^^^^^^^^^^^
  File "D:\Users\j2538\miniconda3\envs\pytf\Lib\site-packages\pymysql\cursors.py", line 322, in _query
    conn.query(q)
  File "D:\Users\j2538\miniconda3\envs\pytf\Lib\site-packages\pymysql\connections.py", line 563, in query
    self._affected_rows = self._read_query_result(unbuffered=unbuffered)
                          ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "D:\Users\j2538\miniconda3\envs\pytf\Lib\site-packages\pymysql\connections.py", line 825, in _read_query_result
    result.read()
  File "D:\Users\j2538\miniconda3\envs\pytf\Lib\site-packages\pymysql\connections.py", line 1199, in read
    first_packet = self.connection._read_packet()
                   ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "D:\Users\j2538\miniconda3\envs\pytf\Lib\site-packages\pymysql\connections.py", line 775, in _read_packet
    packet.raise_for_error()
  File "D:\Users\j2538\miniconda3\envs\pytf\Lib\site-packages\pymysql\protocol.py", line 219, in raise_for_error
    err.raise_mysql_exception(self._data)
  File "D:\Users\j2538\miniconda3\envs\pytf\Lib\site-packages\pymysql\err.py", line 150, in raise_mysql_exception
    raise errorclass(errno, errval)
pymysql.err.OperationalError: (1824, "Failed to open the referenced table 'vwed_script_file'")

The above exception was the direct cause of the following exception:

Traceback (most recent call last):
  File "D:\jsw_code\project\VWED_server\utils\db_migration.py", line 75, in create_table
    model.__table__.create(self.engine)
  File "D:\Users\j2538\miniconda3\envs\pytf\Lib\site-packages\sqlalchemy\sql\schema.py", line 1289, in create
    bind._run_ddl_visitor(ddl.SchemaGenerator, self, checkfirst=checkfirst)
  File "D:\Users\j2538\miniconda3\envs\pytf\Lib\site-packages\sqlalchemy\engine\base.py", line 3249, in _run_ddl_visitor
    conn._run_ddl_visitor(visitorcallable, element, **kwargs)
  File "D:\Users\j2538\miniconda3\envs\pytf\Lib\site-packages\sqlalchemy\engine\base.py", line 2456, in _run_ddl_visitor
    visitorcallable(self.dialect, self, **kwargs).traverse_single(element)
  File "D:\Users\j2538\miniconda3\envs\pytf\Lib\site-packages\sqlalchemy\sql\visitors.py", line 664, in traverse_single
    return meth(obj, **kw)
           ^^^^^^^^^^^^^^^
  File "D:\Users\j2538\miniconda3\envs\pytf\Lib\site-packages\sqlalchemy\sql\ddl.py", line 1016, in visit_table
    )._invoke_with(self.connection)
      ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "D:\Users\j2538\miniconda3\envs\pytf\Lib\site-packages\sqlalchemy\sql\ddl.py", line 314, in _invoke_with
    return bind.execute(self)
           ^^^^^^^^^^^^^^^^^^
  File "D:\Users\j2538\miniconda3\envs\pytf\Lib\site-packages\sqlalchemy\engine\base.py", line 1416, in execute
    return meth(
           ^^^^^
  File "D:\Users\j2538\miniconda3\envs\pytf\Lib\site-packages\sqlalchemy\sql\ddl.py", line 180, in _execute_on_connection
    return connection._execute_ddl(
           ^^^^^^^^^^^^^^^^^^^^^^^^
  File "D:\Users\j2538\miniconda3\envs\pytf\Lib\site-packages\sqlalchemy\engine\base.py", line 1527, in _execute_ddl
    ret = self._execute_context(
          ^^^^^^^^^^^^^^^^^^^^^^
  File "D:\Users\j2538\miniconda3\envs\pytf\Lib\site-packages\sqlalchemy\engine\base.py", line 1843, in _execute_context
    return self._exec_single_context(
           ^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "D:\Users\j2538\miniconda3\envs\pytf\Lib\site-packages\sqlalchemy\engine\base.py", line 1983, in _exec_single_context
    self._handle_dbapi_exception(
  File "D:\Users\j2538\miniconda3\envs\pytf\Lib\site-packages\sqlalchemy\engine\base.py", line 2352, in _handle_dbapi_exception
    raise sqlalchemy_exception.with_traceback(exc_info[2]) from e
  File "D:\Users\j2538\miniconda3\envs\pytf\Lib\site-packages\sqlalchemy\engine\base.py", line 1964, in _exec_single_context
    self.dialect.do_execute(
  File "D:\Users\j2538\miniconda3\envs\pytf\Lib\site-packages\sqlalchemy\engine\default.py", line 942, in do_execute
    cursor.execute(statement, parameters)
  File "D:\Users\j2538\miniconda3\envs\pytf\Lib\site-packages\pymysql\cursors.py", line 153, in execute
    result = self._query(query)
             ^^^^^^^^^^^^^^^^^^
  File "D:\Users\j2538\miniconda3\envs\pytf\Lib\site-packages\pymysql\cursors.py", line 322, in _query
    conn.query(q)
  File "D:\Users\j2538\miniconda3\envs\pytf\Lib\site-packages\pymysql\connections.py", line 563, in query
    self._affected_rows = self._read_query_result(unbuffered=unbuffered)
                          ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "D:\Users\j2538\miniconda3\envs\pytf\Lib\site-packages\pymysql\connections.py", line 825, in _read_query_result
    result.read()
  File "D:\Users\j2538\miniconda3\envs\pytf\Lib\site-packages\pymysql\connections.py", line 1199, in read
    first_packet = self.connection._read_packet()
                   ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "D:\Users\j2538\miniconda3\envs\pytf\Lib\site-packages\pymysql\connections.py", line 775, in _read_packet
    packet.raise_for_error()
  File "D:\Users\j2538\miniconda3\envs\pytf\Lib\site-packages\pymysql\protocol.py", line 219, in raise_for_error
    err.raise_mysql_exception(self._data)
  File "D:\Users\j2538\miniconda3\envs\pytf\Lib\site-packages\pymysql\err.py", line 150, in raise_mysql_exception
    raise errorclass(errno, errval)
sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (1824, "Failed to open the referenced table 'vwed_script_file'")
[SQL: 
CREATE TABLE vwed_script_api_registration (
	id INTEGER NOT NULL COMMENT '注册记录ID' AUTO_INCREMENT, 
	script_id VARCHAR(255) NOT NULL COMMENT '脚本实例ID', 
	file_id INTEGER NOT NULL COMMENT '脚本文件ID', 
	route_path VARCHAR(500) NOT NULL COMMENT '路由路径', 
	http_method VARCHAR(20) NOT NULL COMMENT 'HTTP方法: GET, POST, PUT, DELETE等', 
	handler_name VARCHAR(255) NOT NULL COMMENT '处理函数名', 
	description TEXT COMMENT '接口描述', 
	parameters JSON COMMENT '接口参数定义', 
	response_schema JSON COMMENT '响应格式定义', 
	is_active BOOL COMMENT '是否激活', 
	call_count INTEGER COMMENT '调用次数', 
	last_called_at DATETIME COMMENT '最后调用时间', 
	average_response_time_ms INTEGER COMMENT '平均响应时间(毫秒)', 
	created_at DATETIME NOT NULL COMMENT '注册时间', 
	PRIMARY KEY (id), 
	FOREIGN KEY(file_id) REFERENCES vwed_script_file (id)
)

]
(Background on this error at: https://sqlalche.me/e/20/e3q8)
Stack (most recent call last):
  File "D:\jsw_code\project\VWED_server\scripts\run_migration.py", line 64, in <module>
    main()
  File "D:\jsw_code\project\VWED_server\scripts\run_migration.py", line 53, in main
    success = run_migration()
  File "D:\jsw_code\project\VWED_server\utils\db_migration.py", line 203, in run_migration
    migration.migrate()
  File "D:\jsw_code\project\VWED_server\utils\db_migration.py", line 181, in migrate
    self.create_table(model)
  File "D:\jsw_code\project\VWED_server\utils\db_migration.py", line 79, in create_table
    logger.error(f"创建表 {model.__tablename__} 失败: {str(e)}")
  File "D:\jsw_code\project\VWED_server\utils\logger.py", line 235, in error
    self.logger.error(message, *args, exc_info=exc_info, stack_info=stack_info, **kwargs)
2025-09-11 19:35:48,199 - services.sync_service - INFO - 没有缓存的token，正在获取...
2025-09-11 19:35:48,200 - services.sync_service - INFO - 正在获取登录token，用户: vwed
2025-09-11 19:35:48,200 - utils.db_migration - INFO - 表 vwed_script_execution_log 不存在，准备创建
2025-09-11 19:35:48,203 - utils.db_migration - ERROR - [logger.py:235] - error() - 创建表 vwed_script_execution_log 失败: (pymysql.err.OperationalError) (1824, "Failed to open the referenced table 'vwed_script_file'")
[SQL: 
CREATE TABLE vwed_script_execution_log (
	id INTEGER NOT NULL COMMENT '日志ID' AUTO_INCREMENT, 
	script_id VARCHAR(255) NOT NULL COMMENT '脚本实例ID', 
	file_id INTEGER NOT NULL COMMENT '脚本文件ID', 
	execution_type VARCHAR(50) NOT NULL COMMENT '执行类型: start_service, stop_service, function_call, api_call', 
	function_name VARCHAR(255) COMMENT '执行的函数名', 
	input_params JSON COMMENT '输入参数', 
	output_result JSON COMMENT '输出结果', 
	status VARCHAR(20) NOT NULL COMMENT '执行状态: running, success, failed, timeout', 
	error_message TEXT COMMENT '错误信息', 
	error_traceback TEXT COMMENT '错误堆栈', 
	start_time DATETIME NOT NULL COMMENT '开始时间', 
	end_time DATETIME COMMENT '结束时间', 
	duration_ms INTEGER COMMENT '执行时长(毫秒)', 
	memory_usage_mb FLOAT COMMENT '内存使用(MB)', 
	cpu_usage_percent FLOAT COMMENT 'CPU使用率(%%)', 
	log_level VARCHAR(20) COMMENT '日志级别: DEBUG, INFO, WARNING, ERROR', 
	tags JSON COMMENT '标签信息', 
	created_at DATETIME NOT NULL COMMENT '创建时间', 
	PRIMARY KEY (id), 
	FOREIGN KEY(file_id) REFERENCES vwed_script_file (id)
)

]
(Background on this error at: https://sqlalche.me/e/20/e3q8)
Traceback (most recent call last):
  File "D:\Users\j2538\miniconda3\envs\pytf\Lib\site-packages\sqlalchemy\engine\base.py", line 1964, in _exec_single_context
    self.dialect.do_execute(
  File "D:\Users\j2538\miniconda3\envs\pytf\Lib\site-packages\sqlalchemy\engine\default.py", line 942, in do_execute
    cursor.execute(statement, parameters)
  File "D:\Users\j2538\miniconda3\envs\pytf\Lib\site-packages\pymysql\cursors.py", line 153, in execute
    result = self._query(query)
             ^^^^^^^^^^^^^^^^^^
  File "D:\Users\j2538\miniconda3\envs\pytf\Lib\site-packages\pymysql\cursors.py", line 322, in _query
    conn.query(q)
  File "D:\Users\j2538\miniconda3\envs\pytf\Lib\site-packages\pymysql\connections.py", line 563, in query
    self._affected_rows = self._read_query_result(unbuffered=unbuffered)
                          ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "D:\Users\j2538\miniconda3\envs\pytf\Lib\site-packages\pymysql\connections.py", line 825, in _read_query_result
    result.read()
  File "D:\Users\j2538\miniconda3\envs\pytf\Lib\site-packages\pymysql\connections.py", line 1199, in read
    first_packet = self.connection._read_packet()
                   ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "D:\Users\j2538\miniconda3\envs\pytf\Lib\site-packages\pymysql\connections.py", line 775, in _read_packet
    packet.raise_for_error()
  File "D:\Users\j2538\miniconda3\envs\pytf\Lib\site-packages\pymysql\protocol.py", line 219, in raise_for_error
    err.raise_mysql_exception(self._data)
  File "D:\Users\j2538\miniconda3\envs\pytf\Lib\site-packages\pymysql\err.py", line 150, in raise_mysql_exception
    raise errorclass(errno, errval)
pymysql.err.OperationalError: (1824, "Failed to open the referenced table 'vwed_script_file'")

The above exception was the direct cause of the following exception:

Traceback (most recent call last):
  File "D:\jsw_code\project\VWED_server\utils\db_migration.py", line 75, in create_table
    model.__table__.create(self.engine)
  File "D:\Users\j2538\miniconda3\envs\pytf\Lib\site-packages\sqlalchemy\sql\schema.py", line 1289, in create
    bind._run_ddl_visitor(ddl.SchemaGenerator, self, checkfirst=checkfirst)
  File "D:\Users\j2538\miniconda3\envs\pytf\Lib\site-packages\sqlalchemy\engine\base.py", line 3249, in _run_ddl_visitor
    conn._run_ddl_visitor(visitorcallable, element, **kwargs)
  File "D:\Users\j2538\miniconda3\envs\pytf\Lib\site-packages\sqlalchemy\engine\base.py", line 2456, in _run_ddl_visitor
    visitorcallable(self.dialect, self, **kwargs).traverse_single(element)
  File "D:\Users\j2538\miniconda3\envs\pytf\Lib\site-packages\sqlalchemy\sql\visitors.py", line 664, in traverse_single
    return meth(obj, **kw)
           ^^^^^^^^^^^^^^^
  File "D:\Users\j2538\miniconda3\envs\pytf\Lib\site-packages\sqlalchemy\sql\ddl.py", line 1016, in visit_table
    )._invoke_with(self.connection)
      ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "D:\Users\j2538\miniconda3\envs\pytf\Lib\site-packages\sqlalchemy\sql\ddl.py", line 314, in _invoke_with
    return bind.execute(self)
           ^^^^^^^^^^^^^^^^^^
  File "D:\Users\j2538\miniconda3\envs\pytf\Lib\site-packages\sqlalchemy\engine\base.py", line 1416, in execute
    return meth(
           ^^^^^
  File "D:\Users\j2538\miniconda3\envs\pytf\Lib\site-packages\sqlalchemy\sql\ddl.py", line 180, in _execute_on_connection
    return connection._execute_ddl(
           ^^^^^^^^^^^^^^^^^^^^^^^^
  File "D:\Users\j2538\miniconda3\envs\pytf\Lib\site-packages\sqlalchemy\engine\base.py", line 1527, in _execute_ddl
    ret = self._execute_context(
          ^^^^^^^^^^^^^^^^^^^^^^
  File "D:\Users\j2538\miniconda3\envs\pytf\Lib\site-packages\sqlalchemy\engine\base.py", line 1843, in _execute_context
    return self._exec_single_context(
           ^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "D:\Users\j2538\miniconda3\envs\pytf\Lib\site-packages\sqlalchemy\engine\base.py", line 1983, in _exec_single_context
    self._handle_dbapi_exception(
  File "D:\Users\j2538\miniconda3\envs\pytf\Lib\site-packages\sqlalchemy\engine\base.py", line 2352, in _handle_dbapi_exception
    raise sqlalchemy_exception.with_traceback(exc_info[2]) from e
  File "D:\Users\j2538\miniconda3\envs\pytf\Lib\site-packages\sqlalchemy\engine\base.py", line 1964, in _exec_single_context
    self.dialect.do_execute(
  File "D:\Users\j2538\miniconda3\envs\pytf\Lib\site-packages\sqlalchemy\engine\default.py", line 942, in do_execute
    cursor.execute(statement, parameters)
  File "D:\Users\j2538\miniconda3\envs\pytf\Lib\site-packages\pymysql\cursors.py", line 153, in execute
    result = self._query(query)
             ^^^^^^^^^^^^^^^^^^
  File "D:\Users\j2538\miniconda3\envs\pytf\Lib\site-packages\pymysql\cursors.py", line 322, in _query
    conn.query(q)
  File "D:\Users\j2538\miniconda3\envs\pytf\Lib\site-packages\pymysql\connections.py", line 563, in query
    self._affected_rows = self._read_query_result(unbuffered=unbuffered)
                          ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "D:\Users\j2538\miniconda3\envs\pytf\Lib\site-packages\pymysql\connections.py", line 825, in _read_query_result
    result.read()
  File "D:\Users\j2538\miniconda3\envs\pytf\Lib\site-packages\pymysql\connections.py", line 1199, in read
    first_packet = self.connection._read_packet()
                   ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "D:\Users\j2538\miniconda3\envs\pytf\Lib\site-packages\pymysql\connections.py", line 775, in _read_packet
    packet.raise_for_error()
  File "D:\Users\j2538\miniconda3\envs\pytf\Lib\site-packages\pymysql\protocol.py", line 219, in raise_for_error
    err.raise_mysql_exception(self._data)
  File "D:\Users\j2538\miniconda3\envs\pytf\Lib\site-packages\pymysql\err.py", line 150, in raise_mysql_exception
    raise errorclass(errno, errval)
sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (1824, "Failed to open the referenced table 'vwed_script_file'")
[SQL: 
CREATE TABLE vwed_script_execution_log (
	id INTEGER NOT NULL COMMENT '日志ID' AUTO_INCREMENT, 
	script_id VARCHAR(255) NOT NULL COMMENT '脚本实例ID', 
	file_id INTEGER NOT NULL COMMENT '脚本文件ID', 
	execution_type VARCHAR(50) NOT NULL COMMENT '执行类型: start_service, stop_service, function_call, api_call', 
	function_name VARCHAR(255) COMMENT '执行的函数名', 
	input_params JSON COMMENT '输入参数', 
	output_result JSON COMMENT '输出结果', 
	status VARCHAR(20) NOT NULL COMMENT '执行状态: running, success, failed, timeout', 
	error_message TEXT COMMENT '错误信息', 
	error_traceback TEXT COMMENT '错误堆栈', 
	start_time DATETIME NOT NULL COMMENT '开始时间', 
	end_time DATETIME COMMENT '结束时间', 
	duration_ms INTEGER COMMENT '执行时长(毫秒)', 
	memory_usage_mb FLOAT COMMENT '内存使用(MB)', 
	cpu_usage_percent FLOAT COMMENT 'CPU使用率(%%)', 
	log_level VARCHAR(20) COMMENT '日志级别: DEBUG, INFO, WARNING, ERROR', 
	tags JSON COMMENT '标签信息', 
	created_at DATETIME NOT NULL COMMENT '创建时间', 
	PRIMARY KEY (id), 
	FOREIGN KEY(file_id) REFERENCES vwed_script_file (id)
)

]
(Background on this error at: https://sqlalche.me/e/20/e3q8)
Stack (most recent call last):
  File "D:\jsw_code\project\VWED_server\scripts\run_migration.py", line 64, in <module>
    main()
  File "D:\jsw_code\project\VWED_server\scripts\run_migration.py", line 53, in main
    success = run_migration()
  File "D:\jsw_code\project\VWED_server\utils\db_migration.py", line 203, in run_migration
    migration.migrate()
  File "D:\jsw_code\project\VWED_server\utils\db_migration.py", line 181, in migrate
    self.create_table(model)
  File "D:\jsw_code\project\VWED_server\utils\db_migration.py", line 79, in create_table
    logger.error(f"创建表 {model.__tablename__} 失败: {str(e)}")
  File "D:\jsw_code\project\VWED_server\utils\logger.py", line 235, in error
    self.logger.error(message, *args, exc_info=exc_info, stack_info=stack_info, **kwargs)
2025-09-11 19:35:48,205 - services.sync_service - ERROR - [logger.py:235] - error() - 调用登录接口失败: Header part (1000) from ('X-Tenant-Id', 1000) must be of type str or bytes, not <class 'int'>
Traceback (most recent call last):
  File "D:\jsw_code\project\VWED_server\services\sync_service.py", line 1009, in get_login_token_sync
    response = requests.post(
               ^^^^^^^^^^^^^^
  File "D:\Users\j2538\miniconda3\envs\pytf\Lib\site-packages\requests\api.py", line 115, in post
    return request("post", url, data=data, json=json, **kwargs)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "D:\Users\j2538\miniconda3\envs\pytf\Lib\site-packages\requests\api.py", line 59, in request
    return session.request(method=method, url=url, **kwargs)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "D:\Users\j2538\miniconda3\envs\pytf\Lib\site-packages\requests\sessions.py", line 575, in request
    prep = self.prepare_request(req)
           ^^^^^^^^^^^^^^^^^^^^^^^^^
  File "D:\Users\j2538\miniconda3\envs\pytf\Lib\site-packages\requests\sessions.py", line 484, in prepare_request
    p.prepare(
  File "D:\Users\j2538\miniconda3\envs\pytf\Lib\site-packages\requests\models.py", line 368, in prepare
    self.prepare_headers(headers)
  File "D:\Users\j2538\miniconda3\envs\pytf\Lib\site-packages\requests\models.py", line 490, in prepare_headers
    check_header_validity(header)
  File "D:\Users\j2538\miniconda3\envs\pytf\Lib\site-packages\requests\utils.py", line 1042, in check_header_validity
    _validate_header_part(header, value, 1)
  File "D:\Users\j2538\miniconda3\envs\pytf\Lib\site-packages\requests\utils.py", line 1051, in _validate_header_part
    raise InvalidHeader(
requests.exceptions.InvalidHeader: Header part (1000) from ('X-Tenant-Id', 1000) must be of type str or bytes, not <class 'int'>
Stack (most recent call last):
  File "D:\Users\j2538\miniconda3\envs\pytf\Lib\threading.py", line 1032, in _bootstrap
    self._bootstrap_inner()
  File "D:\Users\j2538\miniconda3\envs\pytf\Lib\threading.py", line 1075, in _bootstrap_inner
    self.run()
  File "D:\Users\j2538\miniconda3\envs\pytf\Lib\threading.py", line 1012, in run
    self._target(*self._args, **self._kwargs)
  File "D:\Users\j2538\miniconda3\envs\pytf\Lib\concurrent\futures\thread.py", line 93, in _worker
    work_item.run()
  File "D:\Users\j2538\miniconda3\envs\pytf\Lib\concurrent\futures\thread.py", line 59, in run
    result = self.fn(*self.args, **self.kwargs)
  File "D:\jsw_code\project\VWED_server\utils\alert_sync.py", line 206, in _send_alert_to_main_system
    token = get_tf_api_token_sync()
  File "D:\jsw_code\project\VWED_server\utils\alert_sync.py", line 28, in get_tf_api_token_sync
    token =  refresh_token_if_needed_sync()
  File "D:\jsw_code\project\VWED_server\services\sync_service.py", line 1068, in refresh_token_if_needed_sync
    return get_login_token_sync()
  File "D:\jsw_code\project\VWED_server\services\sync_service.py", line 1042, in get_login_token_sync
    logger.error(f"调用登录接口失败: {str(e)}")
  File "D:\jsw_code\project\VWED_server\utils\logger.py", line 235, in error
    self.logger.error(message, *args, exc_info=exc_info, stack_info=stack_info, **kwargs)
2025-09-11 19:35:48,212 - services.sync_service - INFO - 没有缓存的token，正在获取...
2025-09-11 19:35:48,212 - utils.db_migration - INFO - 表 vwed_script_file 不存在，准备创建
2025-09-11 19:35:48,219 - services.sync_service - INFO - 正在获取登录token，用户: vwed
2025-09-11 19:35:48,220 - services.sync_service - ERROR - [logger.py:235] - error() - 调用登录接口失败: Header part (1000) from ('X-Tenant-Id', 1000) must be of type str or bytes, not <class 'int'>
Traceback (most recent call last):
  File "D:\jsw_code\project\VWED_server\services\sync_service.py", line 1009, in get_login_token_sync
    response = requests.post(
               ^^^^^^^^^^^^^^
  File "D:\Users\j2538\miniconda3\envs\pytf\Lib\site-packages\requests\api.py", line 115, in post
    return request("post", url, data=data, json=json, **kwargs)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "D:\Users\j2538\miniconda3\envs\pytf\Lib\site-packages\requests\api.py", line 59, in request
    return session.request(method=method, url=url, **kwargs)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "D:\Users\j2538\miniconda3\envs\pytf\Lib\site-packages\requests\sessions.py", line 575, in request
    prep = self.prepare_request(req)
           ^^^^^^^^^^^^^^^^^^^^^^^^^
  File "D:\Users\j2538\miniconda3\envs\pytf\Lib\site-packages\requests\sessions.py", line 484, in prepare_request
    p.prepare(
  File "D:\Users\j2538\miniconda3\envs\pytf\Lib\site-packages\requests\models.py", line 368, in prepare
    self.prepare_headers(headers)
  File "D:\Users\j2538\miniconda3\envs\pytf\Lib\site-packages\requests\models.py", line 490, in prepare_headers
    check_header_validity(header)
  File "D:\Users\j2538\miniconda3\envs\pytf\Lib\site-packages\requests\utils.py", line 1042, in check_header_validity
    _validate_header_part(header, value, 1)
  File "D:\Users\j2538\miniconda3\envs\pytf\Lib\site-packages\requests\utils.py", line 1051, in _validate_header_part
    raise InvalidHeader(
requests.exceptions.InvalidHeader: Header part (1000) from ('X-Tenant-Id', 1000) must be of type str or bytes, not <class 'int'>
Stack (most recent call last):
  File "D:\Users\j2538\miniconda3\envs\pytf\Lib\threading.py", line 1032, in _bootstrap
    self._bootstrap_inner()
  File "D:\Users\j2538\miniconda3\envs\pytf\Lib\threading.py", line 1075, in _bootstrap_inner
    self.run()
  File "D:\Users\j2538\miniconda3\envs\pytf\Lib\threading.py", line 1012, in run
    self._target(*self._args, **self._kwargs)
  File "D:\Users\j2538\miniconda3\envs\pytf\Lib\concurrent\futures\thread.py", line 93, in _worker
    work_item.run()
  File "D:\Users\j2538\miniconda3\envs\pytf\Lib\concurrent\futures\thread.py", line 59, in run
    result = self.fn(*self.args, **self.kwargs)
  File "D:\jsw_code\project\VWED_server\utils\alert_sync.py", line 206, in _send_alert_to_main_system
    token = get_tf_api_token_sync()
  File "D:\jsw_code\project\VWED_server\utils\alert_sync.py", line 28, in get_tf_api_token_sync
    token =  refresh_token_if_needed_sync()
  File "D:\jsw_code\project\VWED_server\services\sync_service.py", line 1068, in refresh_token_if_needed_sync
    return get_login_token_sync()
  File "D:\jsw_code\project\VWED_server\services\sync_service.py", line 1042, in get_login_token_sync
    logger.error(f"调用登录接口失败: {str(e)}")
  File "D:\jsw_code\project\VWED_server\utils\logger.py", line 235, in error
    self.logger.error(message, *args, exc_info=exc_info, stack_info=stack_info, **kwargs)
2025-09-11 19:35:48,221 - utils.db_migration - ERROR - [logger.py:235] - error() - 创建表 vwed_script_file 失败: (pymysql.err.OperationalError) (1824, "Failed to open the referenced table 'vwed_script_project'")
[SQL: 
CREATE TABLE vwed_script_file (
	id INTEGER NOT NULL COMMENT '文件ID' AUTO_INCREMENT, 
	project_id INTEGER NOT NULL COMMENT '所属项目ID', 
	file_name VARCHAR(255) NOT NULL COMMENT '文件名', 
	file_path VARCHAR(500) NOT NULL COMMENT '文件相对路径', 
	file_type VARCHAR(20) NOT NULL COMMENT '文件类型: python, text, json等', 
	content TEXT COMMENT '文件内容', 
	size INTEGER COMMENT '文件大小(字节)', 
	encoding VARCHAR(20) COMMENT '文件编码', 
	is_directory BOOL COMMENT '是否为目录', 
	is_executable BOOL COMMENT '是否可执行', 
	has_boot_function BOOL COMMENT '是否包含boot函数', 
	status VARCHAR(20) NOT NULL COMMENT '文件状态: active, deleted', 
	created_by VARCHAR(100) COMMENT '创建者', 
	created_at DATETIME NOT NULL COMMENT '创建时间', 
	updated_at DATETIME NOT NULL COMMENT '更新时间', 
	PRIMARY KEY (id), 
	FOREIGN KEY(project_id) REFERENCES vwed_script_project (id)
)

]
(Background on this error at: https://sqlalche.me/e/20/e3q8)
Traceback (most recent call last):
  File "D:\Users\j2538\miniconda3\envs\pytf\Lib\site-packages\sqlalchemy\engine\base.py", line 1964, in _exec_single_context
    self.dialect.do_execute(
  File "D:\Users\j2538\miniconda3\envs\pytf\Lib\site-packages\sqlalchemy\engine\default.py", line 942, in do_execute
    cursor.execute(statement, parameters)
  File "D:\Users\j2538\miniconda3\envs\pytf\Lib\site-packages\pymysql\cursors.py", line 153, in execute
    result = self._query(query)
             ^^^^^^^^^^^^^^^^^^
  File "D:\Users\j2538\miniconda3\envs\pytf\Lib\site-packages\pymysql\cursors.py", line 322, in _query
    conn.query(q)
  File "D:\Users\j2538\miniconda3\envs\pytf\Lib\site-packages\pymysql\connections.py", line 563, in query
    self._affected_rows = self._read_query_result(unbuffered=unbuffered)
                          ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "D:\Users\j2538\miniconda3\envs\pytf\Lib\site-packages\pymysql\connections.py", line 825, in _read_query_result
    result.read()
  File "D:\Users\j2538\miniconda3\envs\pytf\Lib\site-packages\pymysql\connections.py", line 1199, in read
    first_packet = self.connection._read_packet()
                   ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "D:\Users\j2538\miniconda3\envs\pytf\Lib\site-packages\pymysql\connections.py", line 775, in _read_packet
    packet.raise_for_error()
  File "D:\Users\j2538\miniconda3\envs\pytf\Lib\site-packages\pymysql\protocol.py", line 219, in raise_for_error
    err.raise_mysql_exception(self._data)
  File "D:\Users\j2538\miniconda3\envs\pytf\Lib\site-packages\pymysql\err.py", line 150, in raise_mysql_exception
    raise errorclass(errno, errval)
pymysql.err.OperationalError: (1824, "Failed to open the referenced table 'vwed_script_project'")

The above exception was the direct cause of the following exception:

Traceback (most recent call last):
  File "D:\jsw_code\project\VWED_server\utils\db_migration.py", line 75, in create_table
    model.__table__.create(self.engine)
  File "D:\Users\j2538\miniconda3\envs\pytf\Lib\site-packages\sqlalchemy\sql\schema.py", line 1289, in create
    bind._run_ddl_visitor(ddl.SchemaGenerator, self, checkfirst=checkfirst)
  File "D:\Users\j2538\miniconda3\envs\pytf\Lib\site-packages\sqlalchemy\engine\base.py", line 3249, in _run_ddl_visitor
    conn._run_ddl_visitor(visitorcallable, element, **kwargs)
  File "D:\Users\j2538\miniconda3\envs\pytf\Lib\site-packages\sqlalchemy\engine\base.py", line 2456, in _run_ddl_visitor
    visitorcallable(self.dialect, self, **kwargs).traverse_single(element)
  File "D:\Users\j2538\miniconda3\envs\pytf\Lib\site-packages\sqlalchemy\sql\visitors.py", line 664, in traverse_single
    return meth(obj, **kw)
           ^^^^^^^^^^^^^^^
  File "D:\Users\j2538\miniconda3\envs\pytf\Lib\site-packages\sqlalchemy\sql\ddl.py", line 1016, in visit_table
    )._invoke_with(self.connection)
      ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "D:\Users\j2538\miniconda3\envs\pytf\Lib\site-packages\sqlalchemy\sql\ddl.py", line 314, in _invoke_with
    return bind.execute(self)
           ^^^^^^^^^^^^^^^^^^
  File "D:\Users\j2538\miniconda3\envs\pytf\Lib\site-packages\sqlalchemy\engine\base.py", line 1416, in execute
    return meth(
           ^^^^^
  File "D:\Users\j2538\miniconda3\envs\pytf\Lib\site-packages\sqlalchemy\sql\ddl.py", line 180, in _execute_on_connection
    return connection._execute_ddl(
           ^^^^^^^^^^^^^^^^^^^^^^^^
  File "D:\Users\j2538\miniconda3\envs\pytf\Lib\site-packages\sqlalchemy\engine\base.py", line 1527, in _execute_ddl
    ret = self._execute_context(
          ^^^^^^^^^^^^^^^^^^^^^^
  File "D:\Users\j2538\miniconda3\envs\pytf\Lib\site-packages\sqlalchemy\engine\base.py", line 1843, in _execute_context
    return self._exec_single_context(
           ^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "D:\Users\j2538\miniconda3\envs\pytf\Lib\site-packages\sqlalchemy\engine\base.py", line 1983, in _exec_single_context
    self._handle_dbapi_exception(
  File "D:\Users\j2538\miniconda3\envs\pytf\Lib\site-packages\sqlalchemy\engine\base.py", line 2352, in _handle_dbapi_exception
    raise sqlalchemy_exception.with_traceback(exc_info[2]) from e
  File "D:\Users\j2538\miniconda3\envs\pytf\Lib\site-packages\sqlalchemy\engine\base.py", line 1964, in _exec_single_context
    self.dialect.do_execute(
  File "D:\Users\j2538\miniconda3\envs\pytf\Lib\site-packages\sqlalchemy\engine\default.py", line 942, in do_execute
    cursor.execute(statement, parameters)
  File "D:\Users\j2538\miniconda3\envs\pytf\Lib\site-packages\pymysql\cursors.py", line 153, in execute
    result = self._query(query)
             ^^^^^^^^^^^^^^^^^^
  File "D:\Users\j2538\miniconda3\envs\pytf\Lib\site-packages\pymysql\cursors.py", line 322, in _query
    conn.query(q)
  File "D:\Users\j2538\miniconda3\envs\pytf\Lib\site-packages\pymysql\connections.py", line 563, in query
    self._affected_rows = self._read_query_result(unbuffered=unbuffered)
                          ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "D:\Users\j2538\miniconda3\envs\pytf\Lib\site-packages\pymysql\connections.py", line 825, in _read_query_result
    result.read()
  File "D:\Users\j2538\miniconda3\envs\pytf\Lib\site-packages\pymysql\connections.py", line 1199, in read
    first_packet = self.connection._read_packet()
                   ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "D:\Users\j2538\miniconda3\envs\pytf\Lib\site-packages\pymysql\connections.py", line 775, in _read_packet
    packet.raise_for_error()
  File "D:\Users\j2538\miniconda3\envs\pytf\Lib\site-packages\pymysql\protocol.py", line 219, in raise_for_error
    err.raise_mysql_exception(self._data)
  File "D:\Users\j2538\miniconda3\envs\pytf\Lib\site-packages\pymysql\err.py", line 150, in raise_mysql_exception
    raise errorclass(errno, errval)
sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (1824, "Failed to open the referenced table 'vwed_script_project'")
[SQL: 
CREATE TABLE vwed_script_file (
	id INTEGER NOT NULL COMMENT '文件ID' AUTO_INCREMENT, 
	project_id INTEGER NOT NULL COMMENT '所属项目ID', 
	file_name VARCHAR(255) NOT NULL COMMENT '文件名', 
	file_path VARCHAR(500) NOT NULL COMMENT '文件相对路径', 
	file_type VARCHAR(20) NOT NULL COMMENT '文件类型: python, text, json等', 
	content TEXT COMMENT '文件内容', 
	size INTEGER COMMENT '文件大小(字节)', 
	encoding VARCHAR(20) COMMENT '文件编码', 
	is_directory BOOL COMMENT '是否为目录', 
	is_executable BOOL COMMENT '是否可执行', 
	has_boot_function BOOL COMMENT '是否包含boot函数', 
	status VARCHAR(20) NOT NULL COMMENT '文件状态: active, deleted', 
	created_by VARCHAR(100) COMMENT '创建者', 
	created_at DATETIME NOT NULL COMMENT '创建时间', 
	updated_at DATETIME NOT NULL COMMENT '更新时间', 
	PRIMARY KEY (id), 
	FOREIGN KEY(project_id) REFERENCES vwed_script_project (id)
)

]
(Background on this error at: https://sqlalche.me/e/20/e3q8)
Stack (most recent call last):
  File "D:\jsw_code\project\VWED_server\scripts\run_migration.py", line 64, in <module>
    main()
  File "D:\jsw_code\project\VWED_server\scripts\run_migration.py", line 53, in main
    success = run_migration()
  File "D:\jsw_code\project\VWED_server\utils\db_migration.py", line 203, in run_migration
    migration.migrate()
  File "D:\jsw_code\project\VWED_server\utils\db_migration.py", line 181, in migrate
    self.create_table(model)
  File "D:\jsw_code\project\VWED_server\utils\db_migration.py", line 79, in create_table
    logger.error(f"创建表 {model.__tablename__} 失败: {str(e)}")
  File "D:\jsw_code\project\VWED_server\utils\logger.py", line 235, in error
    self.logger.error(message, *args, exc_info=exc_info, stack_info=stack_info, **kwargs)
2025-09-11 19:35:48,225 - utils.db_migration - INFO - 表 vwed_script_function_registration 不存在，准备创建
2025-09-11 19:35:48,226 - utils.db_migration - ERROR - [logger.py:235] - error() - 创建表 vwed_script_function_registration 失败: (pymysql.err.OperationalError) (1824, "Failed to open the referenced table 'vwed_script_file'")
[SQL: 
CREATE TABLE vwed_script_function_registration (
	id INTEGER NOT NULL COMMENT '注册记录ID' AUTO_INCREMENT, 
	script_id VARCHAR(255) NOT NULL COMMENT '脚本实例ID', 
	file_id INTEGER NOT NULL COMMENT '脚本文件ID', 
	function_name VARCHAR(255) NOT NULL COMMENT '函数名', 
	handler_name VARCHAR(255) NOT NULL COMMENT '处理函数名(实际函数名)', 
	description TEXT COMMENT '函数描述', 
	parameters JSON COMMENT '参数定义: [{"name": "param1", "type": "str", "required": true}]', 
	return_schema JSON COMMENT '返回值格式定义', 
	is_async BOOL COMMENT '是否为异步函数', 
	is_active BOOL COMMENT '是否激活', 
	call_count INTEGER COMMENT '调用次数', 
	last_called_at DATETIME COMMENT '最后调用时间', 
	average_execution_time_ms INTEGER COMMENT '平均执行时间(毫秒)', 
	success_count INTEGER COMMENT '成功执行次数', 
	error_count INTEGER COMMENT '错误次数', 
	tags JSON COMMENT '函数标签', 
	created_at DATETIME NOT NULL COMMENT '注册时间', 
	PRIMARY KEY (id), 
	FOREIGN KEY(file_id) REFERENCES vwed_script_file (id)
)

]
(Background on this error at: https://sqlalche.me/e/20/e3q8)
Traceback (most recent call last):
  File "D:\Users\j2538\miniconda3\envs\pytf\Lib\site-packages\sqlalchemy\engine\base.py", line 1964, in _exec_single_context
    self.dialect.do_execute(
  File "D:\Users\j2538\miniconda3\envs\pytf\Lib\site-packages\sqlalchemy\engine\default.py", line 942, in do_execute
    cursor.execute(statement, parameters)
  File "D:\Users\j2538\miniconda3\envs\pytf\Lib\site-packages\pymysql\cursors.py", line 153, in execute
    result = self._query(query)
             ^^^^^^^^^^^^^^^^^^
  File "D:\Users\j2538\miniconda3\envs\pytf\Lib\site-packages\pymysql\cursors.py", line 322, in _query
    conn.query(q)
  File "D:\Users\j2538\miniconda3\envs\pytf\Lib\site-packages\pymysql\connections.py", line 563, in query
    self._affected_rows = self._read_query_result(unbuffered=unbuffered)
                          ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "D:\Users\j2538\miniconda3\envs\pytf\Lib\site-packages\pymysql\connections.py", line 825, in _read_query_result
    result.read()
  File "D:\Users\j2538\miniconda3\envs\pytf\Lib\site-packages\pymysql\connections.py", line 1199, in read
    first_packet = self.connection._read_packet()
                   ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "D:\Users\j2538\miniconda3\envs\pytf\Lib\site-packages\pymysql\connections.py", line 775, in _read_packet
    packet.raise_for_error()
  File "D:\Users\j2538\miniconda3\envs\pytf\Lib\site-packages\pymysql\protocol.py", line 219, in raise_for_error
    err.raise_mysql_exception(self._data)
  File "D:\Users\j2538\miniconda3\envs\pytf\Lib\site-packages\pymysql\err.py", line 150, in raise_mysql_exception
    raise errorclass(errno, errval)
pymysql.err.OperationalError: (1824, "Failed to open the referenced table 'vwed_script_file'")

The above exception was the direct cause of the following exception:

Traceback (most recent call last):
  File "D:\jsw_code\project\VWED_server\utils\db_migration.py", line 75, in create_table
    model.__table__.create(self.engine)
  File "D:\Users\j2538\miniconda3\envs\pytf\Lib\site-packages\sqlalchemy\sql\schema.py", line 1289, in create
    bind._run_ddl_visitor(ddl.SchemaGenerator, self, checkfirst=checkfirst)
  File "D:\Users\j2538\miniconda3\envs\pytf\Lib\site-packages\sqlalchemy\engine\base.py", line 3249, in _run_ddl_visitor
    conn._run_ddl_visitor(visitorcallable, element, **kwargs)
  File "D:\Users\j2538\miniconda3\envs\pytf\Lib\site-packages\sqlalchemy\engine\base.py", line 2456, in _run_ddl_visitor
    visitorcallable(self.dialect, self, **kwargs).traverse_single(element)
  File "D:\Users\j2538\miniconda3\envs\pytf\Lib\site-packages\sqlalchemy\sql\visitors.py", line 664, in traverse_single
    return meth(obj, **kw)
           ^^^^^^^^^^^^^^^
  File "D:\Users\j2538\miniconda3\envs\pytf\Lib\site-packages\sqlalchemy\sql\ddl.py", line 1016, in visit_table
    )._invoke_with(self.connection)
      ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "D:\Users\j2538\miniconda3\envs\pytf\Lib\site-packages\sqlalchemy\sql\ddl.py", line 314, in _invoke_with
    return bind.execute(self)
           ^^^^^^^^^^^^^^^^^^
  File "D:\Users\j2538\miniconda3\envs\pytf\Lib\site-packages\sqlalchemy\engine\base.py", line 1416, in execute
    return meth(
           ^^^^^
  File "D:\Users\j2538\miniconda3\envs\pytf\Lib\site-packages\sqlalchemy\sql\ddl.py", line 180, in _execute_on_connection
    return connection._execute_ddl(
           ^^^^^^^^^^^^^^^^^^^^^^^^
  File "D:\Users\j2538\miniconda3\envs\pytf\Lib\site-packages\sqlalchemy\engine\base.py", line 1527, in _execute_ddl
    ret = self._execute_context(
          ^^^^^^^^^^^^^^^^^^^^^^
  File "D:\Users\j2538\miniconda3\envs\pytf\Lib\site-packages\sqlalchemy\engine\base.py", line 1843, in _execute_context
    return self._exec_single_context(
           ^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "D:\Users\j2538\miniconda3\envs\pytf\Lib\site-packages\sqlalchemy\engine\base.py", line 1983, in _exec_single_context
    self._handle_dbapi_exception(
  File "D:\Users\j2538\miniconda3\envs\pytf\Lib\site-packages\sqlalchemy\engine\base.py", line 2352, in _handle_dbapi_exception
    raise sqlalchemy_exception.with_traceback(exc_info[2]) from e
  File "D:\Users\j2538\miniconda3\envs\pytf\Lib\site-packages\sqlalchemy\engine\base.py", line 1964, in _exec_single_context
    self.dialect.do_execute(
  File "D:\Users\j2538\miniconda3\envs\pytf\Lib\site-packages\sqlalchemy\engine\default.py", line 942, in do_execute
    cursor.execute(statement, parameters)
  File "D:\Users\j2538\miniconda3\envs\pytf\Lib\site-packages\pymysql\cursors.py", line 153, in execute
    result = self._query(query)
             ^^^^^^^^^^^^^^^^^^
  File "D:\Users\j2538\miniconda3\envs\pytf\Lib\site-packages\pymysql\cursors.py", line 322, in _query
    conn.query(q)
  File "D:\Users\j2538\miniconda3\envs\pytf\Lib\site-packages\pymysql\connections.py", line 563, in query
    self._affected_rows = self._read_query_result(unbuffered=unbuffered)
                          ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "D:\Users\j2538\miniconda3\envs\pytf\Lib\site-packages\pymysql\connections.py", line 825, in _read_query_result
    result.read()
  File "D:\Users\j2538\miniconda3\envs\pytf\Lib\site-packages\pymysql\connections.py", line 1199, in read
    first_packet = self.connection._read_packet()
                   ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "D:\Users\j2538\miniconda3\envs\pytf\Lib\site-packages\pymysql\connections.py", line 775, in _read_packet
    packet.raise_for_error()
  File "D:\Users\j2538\miniconda3\envs\pytf\Lib\site-packages\pymysql\protocol.py", line 219, in raise_for_error
    err.raise_mysql_exception(self._data)
  File "D:\Users\j2538\miniconda3\envs\pytf\Lib\site-packages\pymysql\err.py", line 150, in raise_mysql_exception
    raise errorclass(errno, errval)
sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (1824, "Failed to open the referenced table 'vwed_script_file'")
[SQL: 
CREATE TABLE vwed_script_function_registration (
	id INTEGER NOT NULL COMMENT '注册记录ID' AUTO_INCREMENT, 
	script_id VARCHAR(255) NOT NULL COMMENT '脚本实例ID', 
	file_id INTEGER NOT NULL COMMENT '脚本文件ID', 
	function_name VARCHAR(255) NOT NULL COMMENT '函数名', 
	handler_name VARCHAR(255) NOT NULL COMMENT '处理函数名(实际函数名)', 
	description TEXT COMMENT '函数描述', 
	parameters JSON COMMENT '参数定义: [{"name": "param1", "type": "str", "required": true}]', 
	return_schema JSON COMMENT '返回值格式定义', 
	is_async BOOL COMMENT '是否为异步函数', 
	is_active BOOL COMMENT '是否激活', 
	call_count INTEGER COMMENT '调用次数', 
	last_called_at DATETIME COMMENT '最后调用时间', 
	average_execution_time_ms INTEGER COMMENT '平均执行时间(毫秒)', 
	success_count INTEGER COMMENT '成功执行次数', 
	error_count INTEGER COMMENT '错误次数', 
	tags JSON COMMENT '函数标签', 
	created_at DATETIME NOT NULL COMMENT '注册时间', 
	PRIMARY KEY (id), 
	FOREIGN KEY(file_id) REFERENCES vwed_script_file (id)
)

]
(Background on this error at: https://sqlalche.me/e/20/e3q8)
Stack (most recent call last):
  File "D:\jsw_code\project\VWED_server\scripts\run_migration.py", line 64, in <module>
    main()
  File "D:\jsw_code\project\VWED_server\scripts\run_migration.py", line 53, in main
    success = run_migration()
  File "D:\jsw_code\project\VWED_server\utils\db_migration.py", line 203, in run_migration
    migration.migrate()
  File "D:\jsw_code\project\VWED_server\utils\db_migration.py", line 181, in migrate
    self.create_table(model)
  File "D:\jsw_code\project\VWED_server\utils\db_migration.py", line 79, in create_table
    logger.error(f"创建表 {model.__tablename__} 失败: {str(e)}")
  File "D:\jsw_code\project\VWED_server\utils\logger.py", line 235, in error
    self.logger.error(message, *args, exc_info=exc_info, stack_info=stack_info, **kwargs)
2025-09-11 19:35:48,228 - utils.db_migration - INFO - 表 vwed_script_project 不存在，准备创建
2025-09-11 19:35:48,270 - utils.db_migration - INFO - 创建表 vwed_script_project 成功
2025-09-11 19:35:48,270 - utils.db_migration - INFO - 表 vwed_script_registry 不存在，准备创建
2025-09-11 19:35:48,271 - utils.db_migration - ERROR - [logger.py:235] - error() - 创建表 vwed_script_registry 失败: (pymysql.err.OperationalError) (1824, "Failed to open the referenced table 'vwed_script_file'")
[SQL: 
CREATE TABLE vwed_script_registry (
	id INTEGER NOT NULL COMMENT '注册记录ID' AUTO_INCREMENT, 
	script_id VARCHAR(255) NOT NULL COMMENT '脚本实例ID', 
	file_id INTEGER NOT NULL COMMENT '脚本文件ID', 
	script_path VARCHAR(500) NOT NULL COMMENT '脚本相对路径', 
	status VARCHAR(20) NOT NULL COMMENT '运行状态: starting, running, stopping, stopped, error', 
	process_id VARCHAR(50) COMMENT '进程ID', 
	host_info JSON COMMENT '主机信息', 
	start_params JSON COMMENT '启动参数', 
	resource_limits JSON COMMENT '资源限制配置', 
	performance_stats JSON COMMENT '性能统计信息', 
	error_message TEXT COMMENT '错误信息', 
	api_count INTEGER COMMENT '注册的API数量', 
	function_count INTEGER COMMENT '注册的函数数量', 
	event_count INTEGER COMMENT '注册的事件监听器数量', 
	timer_count INTEGER COMMENT '注册的定时任务数量', 
	last_heartbeat DATETIME COMMENT '最后心跳时间', 
	started_at DATETIME NOT NULL COMMENT '启动时间', 
	stopped_at DATETIME COMMENT '停止时间', 
	created_at DATETIME NOT NULL COMMENT '创建时间', 
	updated_at DATETIME NOT NULL COMMENT '更新时间', 
	PRIMARY KEY (id), 
	UNIQUE (script_id), 
	FOREIGN KEY(file_id) REFERENCES vwed_script_file (id)
)

]
(Background on this error at: https://sqlalche.me/e/20/e3q8)
Traceback (most recent call last):
  File "D:\Users\j2538\miniconda3\envs\pytf\Lib\site-packages\sqlalchemy\engine\base.py", line 1964, in _exec_single_context
    self.dialect.do_execute(
  File "D:\Users\j2538\miniconda3\envs\pytf\Lib\site-packages\sqlalchemy\engine\default.py", line 942, in do_execute
    cursor.execute(statement, parameters)
  File "D:\Users\j2538\miniconda3\envs\pytf\Lib\site-packages\pymysql\cursors.py", line 153, in execute
    result = self._query(query)
             ^^^^^^^^^^^^^^^^^^
  File "D:\Users\j2538\miniconda3\envs\pytf\Lib\site-packages\pymysql\cursors.py", line 322, in _query
    conn.query(q)
  File "D:\Users\j2538\miniconda3\envs\pytf\Lib\site-packages\pymysql\connections.py", line 563, in query
    self._affected_rows = self._read_query_result(unbuffered=unbuffered)
                          ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "D:\Users\j2538\miniconda3\envs\pytf\Lib\site-packages\pymysql\connections.py", line 825, in _read_query_result
    result.read()
  File "D:\Users\j2538\miniconda3\envs\pytf\Lib\site-packages\pymysql\connections.py", line 1199, in read
    first_packet = self.connection._read_packet()
                   ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "D:\Users\j2538\miniconda3\envs\pytf\Lib\site-packages\pymysql\connections.py", line 775, in _read_packet
    packet.raise_for_error()
  File "D:\Users\j2538\miniconda3\envs\pytf\Lib\site-packages\pymysql\protocol.py", line 219, in raise_for_error
    err.raise_mysql_exception(self._data)
  File "D:\Users\j2538\miniconda3\envs\pytf\Lib\site-packages\pymysql\err.py", line 150, in raise_mysql_exception
    raise errorclass(errno, errval)
pymysql.err.OperationalError: (1824, "Failed to open the referenced table 'vwed_script_file'")

The above exception was the direct cause of the following exception:

Traceback (most recent call last):
  File "D:\jsw_code\project\VWED_server\utils\db_migration.py", line 75, in create_table
    model.__table__.create(self.engine)
  File "D:\Users\j2538\miniconda3\envs\pytf\Lib\site-packages\sqlalchemy\sql\schema.py", line 1289, in create
    bind._run_ddl_visitor(ddl.SchemaGenerator, self, checkfirst=checkfirst)
  File "D:\Users\j2538\miniconda3\envs\pytf\Lib\site-packages\sqlalchemy\engine\base.py", line 3249, in _run_ddl_visitor
    conn._run_ddl_visitor(visitorcallable, element, **kwargs)
  File "D:\Users\j2538\miniconda3\envs\pytf\Lib\site-packages\sqlalchemy\engine\base.py", line 2456, in _run_ddl_visitor
    visitorcallable(self.dialect, self, **kwargs).traverse_single(element)
  File "D:\Users\j2538\miniconda3\envs\pytf\Lib\site-packages\sqlalchemy\sql\visitors.py", line 664, in traverse_single
    return meth(obj, **kw)
           ^^^^^^^^^^^^^^^
  File "D:\Users\j2538\miniconda3\envs\pytf\Lib\site-packages\sqlalchemy\sql\ddl.py", line 1016, in visit_table
    )._invoke_with(self.connection)
      ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "D:\Users\j2538\miniconda3\envs\pytf\Lib\site-packages\sqlalchemy\sql\ddl.py", line 314, in _invoke_with
    return bind.execute(self)
           ^^^^^^^^^^^^^^^^^^
  File "D:\Users\j2538\miniconda3\envs\pytf\Lib\site-packages\sqlalchemy\engine\base.py", line 1416, in execute
    return meth(
           ^^^^^
  File "D:\Users\j2538\miniconda3\envs\pytf\Lib\site-packages\sqlalchemy\sql\ddl.py", line 180, in _execute_on_connection
    return connection._execute_ddl(
           ^^^^^^^^^^^^^^^^^^^^^^^^
  File "D:\Users\j2538\miniconda3\envs\pytf\Lib\site-packages\sqlalchemy\engine\base.py", line 1527, in _execute_ddl
    ret = self._execute_context(
          ^^^^^^^^^^^^^^^^^^^^^^
  File "D:\Users\j2538\miniconda3\envs\pytf\Lib\site-packages\sqlalchemy\engine\base.py", line 1843, in _execute_context
    return self._exec_single_context(
           ^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "D:\Users\j2538\miniconda3\envs\pytf\Lib\site-packages\sqlalchemy\engine\base.py", line 1983, in _exec_single_context
    self._handle_dbapi_exception(
  File "D:\Users\j2538\miniconda3\envs\pytf\Lib\site-packages\sqlalchemy\engine\base.py", line 2352, in _handle_dbapi_exception
    raise sqlalchemy_exception.with_traceback(exc_info[2]) from e
  File "D:\Users\j2538\miniconda3\envs\pytf\Lib\site-packages\sqlalchemy\engine\base.py", line 1964, in _exec_single_context
    self.dialect.do_execute(
  File "D:\Users\j2538\miniconda3\envs\pytf\Lib\site-packages\sqlalchemy\engine\default.py", line 942, in do_execute
    cursor.execute(statement, parameters)
  File "D:\Users\j2538\miniconda3\envs\pytf\Lib\site-packages\pymysql\cursors.py", line 153, in execute
    result = self._query(query)
             ^^^^^^^^^^^^^^^^^^
  File "D:\Users\j2538\miniconda3\envs\pytf\Lib\site-packages\pymysql\cursors.py", line 322, in _query
    conn.query(q)
  File "D:\Users\j2538\miniconda3\envs\pytf\Lib\site-packages\pymysql\connections.py", line 563, in query
    self._affected_rows = self._read_query_result(unbuffered=unbuffered)
                          ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "D:\Users\j2538\miniconda3\envs\pytf\Lib\site-packages\pymysql\connections.py", line 825, in _read_query_result
    result.read()
  File "D:\Users\j2538\miniconda3\envs\pytf\Lib\site-packages\pymysql\connections.py", line 1199, in read
    first_packet = self.connection._read_packet()
                   ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "D:\Users\j2538\miniconda3\envs\pytf\Lib\site-packages\pymysql\connections.py", line 775, in _read_packet
    packet.raise_for_error()
  File "D:\Users\j2538\miniconda3\envs\pytf\Lib\site-packages\pymysql\protocol.py", line 219, in raise_for_error
    err.raise_mysql_exception(self._data)
  File "D:\Users\j2538\miniconda3\envs\pytf\Lib\site-packages\pymysql\err.py", line 150, in raise_mysql_exception
    raise errorclass(errno, errval)
sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (1824, "Failed to open the referenced table 'vwed_script_file'")
[SQL: 
CREATE TABLE vwed_script_registry (
	id INTEGER NOT NULL COMMENT '注册记录ID' AUTO_INCREMENT, 
	script_id VARCHAR(255) NOT NULL COMMENT '脚本实例ID', 
	file_id INTEGER NOT NULL COMMENT '脚本文件ID', 
	script_path VARCHAR(500) NOT NULL COMMENT '脚本相对路径', 
	status VARCHAR(20) NOT NULL COMMENT '运行状态: starting, running, stopping, stopped, error', 
	process_id VARCHAR(50) COMMENT '进程ID', 
	host_info JSON COMMENT '主机信息', 
	start_params JSON COMMENT '启动参数', 
	resource_limits JSON COMMENT '资源限制配置', 
	performance_stats JSON COMMENT '性能统计信息', 
	error_message TEXT COMMENT '错误信息', 
	api_count INTEGER COMMENT '注册的API数量', 
	function_count INTEGER COMMENT '注册的函数数量', 
	event_count INTEGER COMMENT '注册的事件监听器数量', 
	timer_count INTEGER COMMENT '注册的定时任务数量', 
	last_heartbeat DATETIME COMMENT '最后心跳时间', 
	started_at DATETIME NOT NULL COMMENT '启动时间', 
	stopped_at DATETIME COMMENT '停止时间', 
	created_at DATETIME NOT NULL COMMENT '创建时间', 
	updated_at DATETIME NOT NULL COMMENT '更新时间', 
	PRIMARY KEY (id), 
	UNIQUE (script_id), 
	FOREIGN KEY(file_id) REFERENCES vwed_script_file (id)
)

]
(Background on this error at: https://sqlalche.me/e/20/e3q8)
Stack (most recent call last):
  File "D:\jsw_code\project\VWED_server\scripts\run_migration.py", line 64, in <module>
    main()
  File "D:\jsw_code\project\VWED_server\scripts\run_migration.py", line 53, in main
    success = run_migration()
  File "D:\jsw_code\project\VWED_server\utils\db_migration.py", line 203, in run_migration
    migration.migrate()
  File "D:\jsw_code\project\VWED_server\utils\db_migration.py", line 181, in migrate
    self.create_table(model)
  File "D:\jsw_code\project\VWED_server\utils\db_migration.py", line 79, in create_table
    logger.error(f"创建表 {model.__tablename__} 失败: {str(e)}")
  File "D:\jsw_code\project\VWED_server\utils\logger.py", line 235, in error
    self.logger.error(message, *args, exc_info=exc_info, stack_info=stack_info, **kwargs)
2025-09-11 19:35:48,283 - utils.db_migration - INFO - 数据库迁移完成
2025-09-11 19:35:48,283 - utils.db_migration - INFO - 数据库迁移成功
2025-09-11 19:35:48,283 - migration - INFO - 数据库迁移成功完成！
2025-09-11 19:36:21,269 - services.sync_service - INFO - 没有缓存的token，正在获取...
2025-09-11 19:36:21,269 - services.sync_service - INFO - 正在获取登录token，用户: vwed
2025-09-11 19:36:21,271 - services.sync_service - ERROR - [logger.py:235] - error() - 调用登录接口失败: Header part (1000) from ('X-Tenant-Id', 1000) must be of type str or bytes, not <class 'int'>
Traceback (most recent call last):
  File "D:\jsw_code\project\VWED_server\services\sync_service.py", line 1009, in get_login_token_sync
    response = requests.post(
               ^^^^^^^^^^^^^^
  File "D:\Users\j2538\miniconda3\envs\pytf\Lib\site-packages\requests\api.py", line 115, in post
    return request("post", url, data=data, json=json, **kwargs)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "D:\Users\j2538\miniconda3\envs\pytf\Lib\site-packages\requests\api.py", line 59, in request
    return session.request(method=method, url=url, **kwargs)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "D:\Users\j2538\miniconda3\envs\pytf\Lib\site-packages\requests\sessions.py", line 575, in request
    prep = self.prepare_request(req)
           ^^^^^^^^^^^^^^^^^^^^^^^^^
  File "D:\Users\j2538\miniconda3\envs\pytf\Lib\site-packages\requests\sessions.py", line 484, in prepare_request
    p.prepare(
  File "D:\Users\j2538\miniconda3\envs\pytf\Lib\site-packages\requests\models.py", line 368, in prepare
    self.prepare_headers(headers)
  File "D:\Users\j2538\miniconda3\envs\pytf\Lib\site-packages\requests\models.py", line 490, in prepare_headers
    check_header_validity(header)
  File "D:\Users\j2538\miniconda3\envs\pytf\Lib\site-packages\requests\utils.py", line 1042, in check_header_validity
    _validate_header_part(header, value, 1)
  File "D:\Users\j2538\miniconda3\envs\pytf\Lib\site-packages\requests\utils.py", line 1051, in _validate_header_part
    raise InvalidHeader(
requests.exceptions.InvalidHeader: Header part (1000) from ('X-Tenant-Id', 1000) must be of type str or bytes, not <class 'int'>
Stack (most recent call last):
  File "D:\Users\j2538\miniconda3\envs\pytf\Lib\threading.py", line 1032, in _bootstrap
    self._bootstrap_inner()
  File "D:\Users\j2538\miniconda3\envs\pytf\Lib\threading.py", line 1075, in _bootstrap_inner
    self.run()
  File "D:\Users\j2538\miniconda3\envs\pytf\Lib\threading.py", line 1012, in run
    self._target(*self._args, **self._kwargs)
  File "D:\Users\j2538\miniconda3\envs\pytf\Lib\concurrent\futures\thread.py", line 93, in _worker
    work_item.run()
  File "D:\Users\j2538\miniconda3\envs\pytf\Lib\concurrent\futures\thread.py", line 59, in run
    result = self.fn(*self.args, **self.kwargs)
  File "D:\jsw_code\project\VWED_server\utils\alert_sync.py", line 206, in _send_alert_to_main_system
    token = get_tf_api_token_sync()
  File "D:\jsw_code\project\VWED_server\utils\alert_sync.py", line 28, in get_tf_api_token_sync
    token =  refresh_token_if_needed_sync()
  File "D:\jsw_code\project\VWED_server\services\sync_service.py", line 1068, in refresh_token_if_needed_sync
    return get_login_token_sync()
  File "D:\jsw_code\project\VWED_server\services\sync_service.py", line 1042, in get_login_token_sync
    logger.error(f"调用登录接口失败: {str(e)}")
  File "D:\jsw_code\project\VWED_server\utils\logger.py", line 235, in error
    self.logger.error(message, *args, exc_info=exc_info, stack_info=stack_info, **kwargs)
2025-09-11 19:36:21,284 - services.sync_service - INFO - 没有缓存的token，正在获取...
2025-09-11 19:36:21,335 - services.sync_service - INFO - 正在获取登录token，用户: vwed
2025-09-11 19:36:21,341 - services.sync_service - ERROR - [logger.py:235] - error() - 调用登录接口失败: Header part (1000) from ('X-Tenant-Id', 1000) must be of type str or bytes, not <class 'int'>
Traceback (most recent call last):
  File "D:\jsw_code\project\VWED_server\services\sync_service.py", line 1009, in get_login_token_sync
    response = requests.post(
               ^^^^^^^^^^^^^^
  File "D:\Users\j2538\miniconda3\envs\pytf\Lib\site-packages\requests\api.py", line 115, in post
    return request("post", url, data=data, json=json, **kwargs)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "D:\Users\j2538\miniconda3\envs\pytf\Lib\site-packages\requests\api.py", line 59, in request
    return session.request(method=method, url=url, **kwargs)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "D:\Users\j2538\miniconda3\envs\pytf\Lib\site-packages\requests\sessions.py", line 575, in request
    prep = self.prepare_request(req)
           ^^^^^^^^^^^^^^^^^^^^^^^^^
  File "D:\Users\j2538\miniconda3\envs\pytf\Lib\site-packages\requests\sessions.py", line 484, in prepare_request
    p.prepare(
  File "D:\Users\j2538\miniconda3\envs\pytf\Lib\site-packages\requests\models.py", line 368, in prepare
    self.prepare_headers(headers)
  File "D:\Users\j2538\miniconda3\envs\pytf\Lib\site-packages\requests\models.py", line 490, in prepare_headers
    check_header_validity(header)
  File "D:\Users\j2538\miniconda3\envs\pytf\Lib\site-packages\requests\utils.py", line 1042, in check_header_validity
    _validate_header_part(header, value, 1)
  File "D:\Users\j2538\miniconda3\envs\pytf\Lib\site-packages\requests\utils.py", line 1051, in _validate_header_part
    raise InvalidHeader(
requests.exceptions.InvalidHeader: Header part (1000) from ('X-Tenant-Id', 1000) must be of type str or bytes, not <class 'int'>
Stack (most recent call last):
  File "D:\Users\j2538\miniconda3\envs\pytf\Lib\threading.py", line 1032, in _bootstrap
    self._bootstrap_inner()
  File "D:\Users\j2538\miniconda3\envs\pytf\Lib\threading.py", line 1075, in _bootstrap_inner
    self.run()
  File "D:\Users\j2538\miniconda3\envs\pytf\Lib\threading.py", line 1012, in run
    self._target(*self._args, **self._kwargs)
  File "D:\Users\j2538\miniconda3\envs\pytf\Lib\concurrent\futures\thread.py", line 93, in _worker
    work_item.run()
  File "D:\Users\j2538\miniconda3\envs\pytf\Lib\concurrent\futures\thread.py", line 59, in run
    result = self.fn(*self.args, **self.kwargs)
  File "D:\jsw_code\project\VWED_server\utils\alert_sync.py", line 206, in _send_alert_to_main_system
    token = get_tf_api_token_sync()
  File "D:\jsw_code\project\VWED_server\utils\alert_sync.py", line 28, in get_tf_api_token_sync
    token =  refresh_token_if_needed_sync()
  File "D:\jsw_code\project\VWED_server\services\sync_service.py", line 1068, in refresh_token_if_needed_sync
    return get_login_token_sync()
  File "D:\jsw_code\project\VWED_server\services\sync_service.py", line 1042, in get_login_token_sync
    logger.error(f"调用登录接口失败: {str(e)}")
  File "D:\jsw_code\project\VWED_server\utils\logger.py", line 235, in error
    self.logger.error(message, *args, exc_info=exc_info, stack_info=stack_info, **kwargs)
2025-09-11 19:36:45,532 - services.sync_service - INFO - 没有缓存的token，正在获取...
2025-09-11 19:36:45,532 - services.sync_service - INFO - 正在获取登录token，用户: vwed
2025-09-11 19:36:45,532 - services.sync_service - ERROR - [logger.py:235] - error() - 调用登录接口失败: Header part (1000) from ('X-Tenant-Id', 1000) must be of type str or bytes, not <class 'int'>
Traceback (most recent call last):
  File "D:\jsw_code\project\VWED_server\services\sync_service.py", line 1009, in get_login_token_sync
    response = requests.post(
               ^^^^^^^^^^^^^^
  File "D:\Users\j2538\miniconda3\envs\pytf\Lib\site-packages\requests\api.py", line 115, in post
    return request("post", url, data=data, json=json, **kwargs)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "D:\Users\j2538\miniconda3\envs\pytf\Lib\site-packages\requests\api.py", line 59, in request
    return session.request(method=method, url=url, **kwargs)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "D:\Users\j2538\miniconda3\envs\pytf\Lib\site-packages\requests\sessions.py", line 575, in request
    prep = self.prepare_request(req)
           ^^^^^^^^^^^^^^^^^^^^^^^^^
  File "D:\Users\j2538\miniconda3\envs\pytf\Lib\site-packages\requests\sessions.py", line 484, in prepare_request
    p.prepare(
  File "D:\Users\j2538\miniconda3\envs\pytf\Lib\site-packages\requests\models.py", line 368, in prepare
    self.prepare_headers(headers)
  File "D:\Users\j2538\miniconda3\envs\pytf\Lib\site-packages\requests\models.py", line 490, in prepare_headers
    check_header_validity(header)
  File "D:\Users\j2538\miniconda3\envs\pytf\Lib\site-packages\requests\utils.py", line 1042, in check_header_validity
    _validate_header_part(header, value, 1)
  File "D:\Users\j2538\miniconda3\envs\pytf\Lib\site-packages\requests\utils.py", line 1051, in _validate_header_part
    raise InvalidHeader(
requests.exceptions.InvalidHeader: Header part (1000) from ('X-Tenant-Id', 1000) must be of type str or bytes, not <class 'int'>
Stack (most recent call last):
  File "D:\Users\j2538\miniconda3\envs\pytf\Lib\threading.py", line 1032, in _bootstrap
    self._bootstrap_inner()
  File "D:\Users\j2538\miniconda3\envs\pytf\Lib\threading.py", line 1075, in _bootstrap_inner
    self.run()
  File "D:\Users\j2538\miniconda3\envs\pytf\Lib\threading.py", line 1012, in run
    self._target(*self._args, **self._kwargs)
  File "D:\Users\j2538\miniconda3\envs\pytf\Lib\concurrent\futures\thread.py", line 93, in _worker
    work_item.run()
  File "D:\Users\j2538\miniconda3\envs\pytf\Lib\concurrent\futures\thread.py", line 59, in run
    result = self.fn(*self.args, **self.kwargs)
  File "D:\jsw_code\project\VWED_server\utils\alert_sync.py", line 206, in _send_alert_to_main_system
    token = get_tf_api_token_sync()
  File "D:\jsw_code\project\VWED_server\utils\alert_sync.py", line 28, in get_tf_api_token_sync
    token =  refresh_token_if_needed_sync()
  File "D:\jsw_code\project\VWED_server\services\sync_service.py", line 1068, in refresh_token_if_needed_sync
    return get_login_token_sync()
  File "D:\jsw_code\project\VWED_server\services\sync_service.py", line 1042, in get_login_token_sync
    logger.error(f"调用登录接口失败: {str(e)}")
  File "D:\jsw_code\project\VWED_server\utils\logger.py", line 235, in error
    self.logger.error(message, *args, exc_info=exc_info, stack_info=stack_info, **kwargs)
2025-09-11 19:36:46,026 - services.sync_service - INFO - 没有缓存的token，正在获取...
2025-09-11 19:36:46,026 - services.sync_service - INFO - 正在获取登录token，用户: vwed
2025-09-11 19:36:46,027 - services.sync_service - ERROR - [logger.py:235] - error() - 调用登录接口失败: Header part (1000) from ('X-Tenant-Id', 1000) must be of type str or bytes, not <class 'int'>
Traceback (most recent call last):
  File "D:\jsw_code\project\VWED_server\services\sync_service.py", line 1009, in get_login_token_sync
    response = requests.post(
               ^^^^^^^^^^^^^^
  File "D:\Users\j2538\miniconda3\envs\pytf\Lib\site-packages\requests\api.py", line 115, in post
    return request("post", url, data=data, json=json, **kwargs)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "D:\Users\j2538\miniconda3\envs\pytf\Lib\site-packages\requests\api.py", line 59, in request
    return session.request(method=method, url=url, **kwargs)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "D:\Users\j2538\miniconda3\envs\pytf\Lib\site-packages\requests\sessions.py", line 575, in request
    prep = self.prepare_request(req)
           ^^^^^^^^^^^^^^^^^^^^^^^^^
  File "D:\Users\j2538\miniconda3\envs\pytf\Lib\site-packages\requests\sessions.py", line 484, in prepare_request
    p.prepare(
  File "D:\Users\j2538\miniconda3\envs\pytf\Lib\site-packages\requests\models.py", line 368, in prepare
    self.prepare_headers(headers)
  File "D:\Users\j2538\miniconda3\envs\pytf\Lib\site-packages\requests\models.py", line 490, in prepare_headers
    check_header_validity(header)
  File "D:\Users\j2538\miniconda3\envs\pytf\Lib\site-packages\requests\utils.py", line 1042, in check_header_validity
    _validate_header_part(header, value, 1)
  File "D:\Users\j2538\miniconda3\envs\pytf\Lib\site-packages\requests\utils.py", line 1051, in _validate_header_part
    raise InvalidHeader(
requests.exceptions.InvalidHeader: Header part (1000) from ('X-Tenant-Id', 1000) must be of type str or bytes, not <class 'int'>
Stack (most recent call last):
  File "D:\Users\j2538\miniconda3\envs\pytf\Lib\threading.py", line 1032, in _bootstrap
    self._bootstrap_inner()
  File "D:\Users\j2538\miniconda3\envs\pytf\Lib\threading.py", line 1075, in _bootstrap_inner
    self.run()
  File "D:\Users\j2538\miniconda3\envs\pytf\Lib\threading.py", line 1012, in run
    self._target(*self._args, **self._kwargs)
  File "D:\Users\j2538\miniconda3\envs\pytf\Lib\concurrent\futures\thread.py", line 93, in _worker
    work_item.run()
  File "D:\Users\j2538\miniconda3\envs\pytf\Lib\concurrent\futures\thread.py", line 59, in run
    result = self.fn(*self.args, **self.kwargs)
  File "D:\jsw_code\project\VWED_server\utils\alert_sync.py", line 206, in _send_alert_to_main_system
    token = get_tf_api_token_sync()
  File "D:\jsw_code\project\VWED_server\utils\alert_sync.py", line 28, in get_tf_api_token_sync
    token =  refresh_token_if_needed_sync()
  File "D:\jsw_code\project\VWED_server\services\sync_service.py", line 1068, in refresh_token_if_needed_sync
    return get_login_token_sync()
  File "D:\jsw_code\project\VWED_server\services\sync_service.py", line 1042, in get_login_token_sync
    logger.error(f"调用登录接口失败: {str(e)}")
  File "D:\jsw_code\project\VWED_server\utils\logger.py", line 235, in error
    self.logger.error(message, *args, exc_info=exc_info, stack_info=stack_info, **kwargs)
2025-09-11 19:37:18,377 - services.sync_service - INFO - 没有缓存的token，正在获取...
2025-09-11 19:37:18,378 - services.sync_service - INFO - 正在获取登录token，用户: vwed
2025-09-11 19:37:18,378 - services.sync_service - ERROR - [logger.py:235] - error() - 调用登录接口失败: Header part (1000) from ('X-Tenant-Id', 1000) must be of type str or bytes, not <class 'int'>
Traceback (most recent call last):
  File "D:\jsw_code\project\VWED_server\services\sync_service.py", line 1009, in get_login_token_sync
    response = requests.post(
               ^^^^^^^^^^^^^^
  File "D:\Users\j2538\miniconda3\envs\pytf\Lib\site-packages\requests\api.py", line 115, in post
    return request("post", url, data=data, json=json, **kwargs)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "D:\Users\j2538\miniconda3\envs\pytf\Lib\site-packages\requests\api.py", line 59, in request
    return session.request(method=method, url=url, **kwargs)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "D:\Users\j2538\miniconda3\envs\pytf\Lib\site-packages\requests\sessions.py", line 575, in request
    prep = self.prepare_request(req)
           ^^^^^^^^^^^^^^^^^^^^^^^^^
  File "D:\Users\j2538\miniconda3\envs\pytf\Lib\site-packages\requests\sessions.py", line 484, in prepare_request
    p.prepare(
  File "D:\Users\j2538\miniconda3\envs\pytf\Lib\site-packages\requests\models.py", line 368, in prepare
    self.prepare_headers(headers)
  File "D:\Users\j2538\miniconda3\envs\pytf\Lib\site-packages\requests\models.py", line 490, in prepare_headers
    check_header_validity(header)
  File "D:\Users\j2538\miniconda3\envs\pytf\Lib\site-packages\requests\utils.py", line 1042, in check_header_validity
    _validate_header_part(header, value, 1)
  File "D:\Users\j2538\miniconda3\envs\pytf\Lib\site-packages\requests\utils.py", line 1051, in _validate_header_part
    raise InvalidHeader(
requests.exceptions.InvalidHeader: Header part (1000) from ('X-Tenant-Id', 1000) must be of type str or bytes, not <class 'int'>
Stack (most recent call last):
  File "D:\Users\j2538\miniconda3\envs\pytf\Lib\threading.py", line 1032, in _bootstrap
    self._bootstrap_inner()
  File "D:\Users\j2538\miniconda3\envs\pytf\Lib\threading.py", line 1075, in _bootstrap_inner
    self.run()
  File "D:\Users\j2538\miniconda3\envs\pytf\Lib\threading.py", line 1012, in run
    self._target(*self._args, **self._kwargs)
  File "D:\Users\j2538\miniconda3\envs\pytf\Lib\concurrent\futures\thread.py", line 93, in _worker
    work_item.run()
  File "D:\Users\j2538\miniconda3\envs\pytf\Lib\concurrent\futures\thread.py", line 59, in run
    result = self.fn(*self.args, **self.kwargs)
  File "D:\jsw_code\project\VWED_server\utils\alert_sync.py", line 206, in _send_alert_to_main_system
    token = get_tf_api_token_sync()
  File "D:\jsw_code\project\VWED_server\utils\alert_sync.py", line 28, in get_tf_api_token_sync
    token =  refresh_token_if_needed_sync()
  File "D:\jsw_code\project\VWED_server\services\sync_service.py", line 1068, in refresh_token_if_needed_sync
    return get_login_token_sync()
  File "D:\jsw_code\project\VWED_server\services\sync_service.py", line 1042, in get_login_token_sync
    logger.error(f"调用登录接口失败: {str(e)}")
  File "D:\jsw_code\project\VWED_server\utils\logger.py", line 235, in error
    self.logger.error(message, *args, exc_info=exc_info, stack_info=stack_info, **kwargs)
