Closed
Description
Search before asking
- I had searched in the issues and found no similar issues.
Apache ShenYu Component
shenyu-admin
What happened
MockRequestRecordServiceImpl.queryByApiId(...) returns the first row from selectByQuery(...):
MockRequestRecordQuery mockRequestRecordQuery = new MockRequestRecordQuery();
mockRequestRecordQuery.setApiId(apiId);
List<MockRequestRecordDO> mockRequestRecordDOList = mockRequestRecordMapper.selectByQuery(mockRequestRecordQuery);
return mockRequestRecordDOList.isEmpty()
? new MockRequestRecordVO()
: MockRequestRecordVO.buildMockRequestRecordVO(mockRequestRecordDOList.get(0));But the mapper query has no ORDER BY:
<select id="selectByQuery" ...>
SELECT ...
FROM mock_request_record
<where>
<if test="apiId != null">
and api_id = #{apiId, jdbcType=VARCHAR}
</if>
...
</where>
</select>and the table schema only defines id as the primary key. There is no uniqueness constraint on api_id:
CREATE TABLE `mock_request_record` (
`id` varchar(128) NOT NULL,
`api_id` varchar(128) NOT NULL,
...
PRIMARY KEY (`id`)
)If multiple mock request records exist for the same apiId, the returned record depends on the database execution plan and can change unpredictably.
Expected behavior
queryByApiId(...) should be deterministic. It should either enforce a unique mock request record per apiId, add a deterministic ordering and selection rule, or return all matching records instead of silently picking the first unordered row.
How to reproduce
- Insert or create two
mock_request_recordrows with the sameapi_idand different request data. - Call the admin API path that uses
MockRequestRecordServiceImpl.queryByApiId(apiId). - The service returns
selectByQuery(...).get(0)without any SQL ordering or uniqueness guarantee. - Which mock record is returned is not stable across database plans/storage state.
Debug logs
No response
Environment
Current master branch.
Are you willing to submit a PR?
- Yes I am willing to submit a PR!
Metadata
Metadata
Assignees
Labels
No labels
Activity
github-actions commentedon Jul 31, 2026
👋 Hello @yuluo-yx
A new issue has been opened by @Aias00:
Please review when you have time. Thank you! 🙏