You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I reproduced this against the core parser path on the current APIJSONORM master (c96950f7) with a DB-free harness. I did not retest the demo project's outer /register endpoint. When User/id@ is parsed before Privacy/id and the target value is not yet available:
for POST and PUT, the User table object does not throw; it is invalidated and parse() returns null, so no SQL is generated or executed;
the complete parseResponse still returns code: 200, msg: success, with zero generated and executed SQL statements;
GET also returns success, while an unresolved reference in a non-table object during POST is silently discarded.
In the current code, unresolved references are handled in the target == null branch of AbstractObjectParser.onParse; the old targetPath.equals(target) branch is now commented out, and the current branch distinguishes table-field references from non-table-object references. Before making a change, could you please confirm two scope details?
When the object's effective method is POST or PUT, should the exception guard run before the current isTable branch, covering every unresolved string reference (closest to your original suggestion), or only table-field references that invalidate the table object?
By UnsupportedException in your original comment, did you mean UnsupportedOperationException, which exists in the current codebase?
Once confirmed, I would scope the change to this reference-resolution branch and add DB-free behavioral tests covering the agreed cases: unresolved POST/PUT references fail, while GET and successfully resolved references retain their current behavior. The tests would assert behavior and exception type rather than any exact error message text.
I haven't started implementing this, I'll wait for your confirmation before opening a PR.
I reproduced this against the core parser path on the current APIJSONORM master (c96950f7) with a DB-free harness. I did not retest the demo project's outer /register endpoint. When User/id@ is parsed before Privacy/id and the target value is not yet available:
for POST and PUT, the User table object does not throw; it is invalidated and parse() returns null, so no SQL is generated or executed;
the complete parseResponse still returns code: 200, msg: success, with zero generated and executed SQL statements;
GET also returns success, while an unresolved reference in a non-table object during POST is silently discarded.
In the current code, unresolved references are handled in the target == null branch of AbstractObjectParser.onParse; the old targetPath.equals(target) branch is now commented out, and the current branch distinguishes table-field references from non-table-object references. Before making a change, could you please confirm two scope details?
When the object's effective method is POST or PUT, should the exception guard run before the current isTable branch, covering every unresolved string reference (closest to your original suggestion), or only table-field references that invalidate the table object?
By UnsupportedException in your original comment, did you mean UnsupportedOperationException, which exists in the current codebase?
Once confirmed, I would scope the change to this reference-resolution branch and add DB-free behavioral tests covering the agreed cases: unresolved POST/PUT references fail, while GET and successfully resolved references retain their current behavior. The tests would assert behavior and exception type rather than any exact error message text.
I haven't started implementing this, I'll wait for your confirmation before opening a PR.
@henriquejsza Thank you for your feedback
1.Yes, the exception should be thrown and abort all next operations, in case the wrong request will continue to be resolved and result in unexpected behaviors.
2.Yes, it should be UnsupportedOperationException.
Activity
jerrylususu commentedon Jul 28, 2021
这一问题在使用
/register端点的时候同样存在,但因为一部分处理操作包在了方法体内部(例如parseResponse(requestObject)),使得找出问题原因更加困难。以相同输入,POST
/register得到的返回值(实际用户注册是失败的){ "ok": true, "code": 200, "msg": "success" }如果输入顺序正常,正常的返回
{ "privacy": { "ok": true, "code": 200, "msg": "success", "count": 1, "id": 1627508021086 }, "user": { "ok": true, "code": 200, "msg": "success", "count": 1, "id": 1627508021086 }, "verify": "6533", "ok": true, "code": 200, "msg": "success" }TommyLemon commentedon Jul 31, 2021
原因:引用赋值查不到对应被引用的值时,只是终止处理当期对象。
规范是必须按照顺序来,但是 Request 表中配置的 json 类型 structure 会被 MySQL 强制自动按 ASCII 编码排序,只能提供文档说明顺序。
如果要直接从代码上保证,应该对 AbstractObjectParser. onParse 385 和 395 行两个 if 中加上判断
method == POST || method == PUT 时 throw UnsupportedException("引用赋值 " + path + "/" + key + ": " + targetPath + " 解析失败,POST 和 PUT 接口必须保证每个对象执行都成功!")
https://github.com/Tencent/APIJSON/blob/3ccd9674ce572e36907dd961ae9386e31abc2483/APIJSONORM/src/main/java/apijson/orm/AbstractObjectParser.java
这个影响不大,暂时没时间去修改和测试,你可以提个 PR,合并后会把你加入贡献者名单,开源要大家一起共建才会更美好~

https://github.com/Tencent/APIJSON/blob/master/CONTRIBUTING.md
henriquejsza commentedon Aug 30, 2026
I reproduced this against the core parser path on the current APIJSONORM
master(c96950f7) with a DB-free harness. I did not retest the demo project's outer/registerendpoint. WhenUser/id@is parsed beforePrivacy/idand the target value is not yet available:Usertable object does not throw; it is invalidated andparse()returnsnull, so no SQL is generated or executed;parseResponsestill returnscode: 200, msg: success, with zero generated and executed SQL statements;In the current code, unresolved references are handled in the
target == nullbranch ofAbstractObjectParser.onParse; the oldtargetPath.equals(target)branch is now commented out, and the current branch distinguishes table-field references from non-table-object references. Before making a change, could you please confirm two scope details?isTablebranch, covering every unresolved string reference (closest to your original suggestion), or only table-field references that invalidate the table object?UnsupportedExceptionin your original comment, did you meanUnsupportedOperationException, which exists in the current codebase?Once confirmed, I would scope the change to this reference-resolution branch and add DB-free behavioral tests covering the agreed cases: unresolved POST/PUT references fail, while GET and successfully resolved references retain their current behavior. The tests would assert behavior and exception type rather than any exact error message text.
I haven't started implementing this, I'll wait for your confirmation before opening a PR.
TommyLemon commentedon Aug 31, 2026
@henriquejsza Thank you for your feedback
1.Yes, the exception should be thrown and abort all next operations, in case the wrong request will continue to be resolved and result in unexpected behaviors.
2.Yes, it should be UnsupportedOperationException.
Looking forward to your PR~
fix: reject unresolved POST and PUT references