Fixes #25878: listBots API does not return botUser field#27527
Fixes #25878: listBots API does not return botUser field#27527kratipaliwal wants to merge 3 commits intoopen-metadata:mainfrom
Conversation
|
Hi there 👋 Thanks for your contribution! The OpenMetadata team will review the PR shortly! Once it has been labeled as Let us know if you need any help! |
|
Hi there 👋 Thanks for your contribution! The OpenMetadata team will review the PR shortly! Once it has been labeled as Let us know if you need any help! |
Code Review ✅ Approved 1 resolved / 1 findingsUpdates the listBots API to correctly populate the botUser field, addressing the N+1 database lookup inefficiency during batch bot user fetching. No further issues found. ✅ 1 resolved✅ Performance: batchFetchBotUsers still does N individual DB lookups per user
OptionsDisplay: compact → Showing less information. Comment with these commands to change:
Was this helpful? React with 👍 / 👎 | Gitar |
|
🟡 Playwright Results — all passed (14 flaky)✅ 3959 passed · ❌ 0 failed · 🟡 14 flaky · ⏭️ 86 skipped
🟡 14 flaky test(s) (passed on retry)
How to debug locally# Download playwright-test-results-<shard> artifact and unzip
npx playwright show-trace path/to/trace.zip # view trace |



Describe your changes:
Fixes #25878
GET /v1/bots(list) was never returning thebotUserfield, even when callers explicitly asked for it with?fields=botUser. ExistingGET /v1/bots/{id}andGET /v1/bots/name/{name}continued to returnbotUseras before.Two independent bugs produced this:
BotResourcedid not expose afieldsquery parameter.list(),get(), andgetByName()hardcoded""for fields, so?fields=botUserwas silently ignored.BotRepositoryonly populatedbotUserviasetFields(single-entity path). The list endpoint usessetFieldsInBulk→fetchAndSetFields, which dispatches through registeredfieldFetchers. Combined withgetFieldsStrippedFromStorageJson()strippingbotUserfrom stored JSON, listed bots came back without it.Fix
BotResource: added aFIELDS = "botUser"constant and a@QueryParam("fields")onlist,get, andgetByName, forwarded to the internal handlers (previously the param was silently dropped).BotRepository: overrodesetFieldsInBulkto batch-fetchbotUserviarelationshipDAO.findToBatch(..., CONTAINS, USER)whenfields.contains("botUser"). Single-entitysetFieldsremains unconditional to preserve backward compatibility for existing UI and SDK callers ofGET /bots/{id}andGET /bots/name/{name}.Final behavior
?fieldsnot passed?fields=botUserGET /v1/bots/{id}botUserreturned (unchanged)botUserreturnedGET /v1/bots/name/{name}botUserreturned (unchanged)botUserreturnedGET /v1/bots(list)botUseromittedbotUserreturnedNo breaking change for existing consumers of the single-entity GET endpoints. The list endpoint gains the missing
?fields=botUsersupport described in the Swagger docs.Tests
Added regression integration tests in
BotResourceITcovering the list, get, create, and patch paths:test_listBots_withoutFieldsParam_omitsBotUser— list without?fieldsdoes not populatebotUser.test_listBots_withFieldsParam_returnsBotUser— list with?fields=botUserreturns the relationship.test_listBots_multipleBots_allHaveBotUser— exercises the bulk-fetch code path with multiple bots.test_getBotById_alwaysReturnsBotUser/test_getBotByName_alwaysReturnsBotUser— backward-compat guards: single-entity GETs must continue to returnbotUserwithout?fields.test_getBotById_withFieldsParam_returnsBotUser/test_getBotByName_withFieldsParam_returnsBotUser— explicit?fields=botUserstill works on single-entity GETs.test_createBot_responseIncludesBotUser— POST response continues to includebotUser.test_patchBotDescription_preservesBotUser— patching description does not drop thebotUserrelationship.test_patchBot_cannotChangeBotUser— guards the immutability contract inrestorePatchAttributes.Type of change:
Checklist:
Fixes <issue-number>: <short explanation>Summary by Gitar
fieldChangedfiltering to thelistVersionsendpoint inBotResource.getVersionHistoryPaginatedandgetVersionHistoryWithFieldChangedinBotResourceITto support verifying extended version history.This will update automatically on new commits.