fix: remove visitor token from visitors.info endpoint#40581
Conversation
🦋 Changeset detectedLatest commit: 1a2d36c The changes in this PR will be included in the next version bump. This PR includes changesets to release 40 packages
Not sure what this means? Click here to learn what changesets are. Click here if you're a maintainer who wants to add another changeset to this PR |
There was a problem hiding this comment.
1 issue found across 3 files
Prompt for AI agents (unresolved issues)
Check if these issues are valid — if so, understand the root cause of each and fix them. If appropriate, use sub-agents to investigate and fix each issue separately.
<file name="apps/meteor/app/livechat/server/api/lib/visitors.ts">
<violation number="1" location="apps/meteor/app/livechat/server/api/lib/visitors.ts:9">
P2: Excluding `token` here changes the endpoint response shape, but the typed contract still returns `ILivechatVisitor` (which requires `token`). Update the REST response type for `/v1/livechat/visitors.info` to match the projected data.
(Based on your team's feedback about keeping API typings aligned with runtime endpoint behavior.) [FEEDBACK_USED]</violation>
</file>
Reply with feedback, questions, or to request a fix. Tag @cubic-dev-ai to re-run a review.
Re-trigger cubic
|
|
||
| export async function findVisitorInfo({ visitorId }: { visitorId: IVisitor['_id'] }) { | ||
| const visitor = await LivechatVisitors.findOneEnabledById(visitorId); | ||
| const visitor = await LivechatVisitors.findOneEnabledById(visitorId, { projection: { token: 0 } }); |
There was a problem hiding this comment.
P2: Excluding token here changes the endpoint response shape, but the typed contract still returns ILivechatVisitor (which requires token). Update the REST response type for /v1/livechat/visitors.info to match the projected data.
(Based on your team's feedback about keeping API typings aligned with runtime endpoint behavior.)
Prompt for AI agents
Check if this issue is valid — if so, understand the root cause and fix it. At apps/meteor/app/livechat/server/api/lib/visitors.ts, line 9:
<comment>Excluding `token` here changes the endpoint response shape, but the typed contract still returns `ILivechatVisitor` (which requires `token`). Update the REST response type for `/v1/livechat/visitors.info` to match the projected data.
(Based on your team's feedback about keeping API typings aligned with runtime endpoint behavior.) </comment>
<file context>
@@ -6,7 +6,7 @@ import { callbacks } from '../../../../../server/lib/callbacks';
export async function findVisitorInfo({ visitorId }: { visitorId: IVisitor['_id'] }) {
- const visitor = await LivechatVisitors.findOneEnabledById(visitorId);
+ const visitor = await LivechatVisitors.findOneEnabledById(visitorId, { projection: { token: 0 } });
if (!visitor) {
throw new Error('visitor-not-found');
</file context>
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## release-8.0.6 #40581 +/- ##
================================================
Coverage ? 70.71%
================================================
Files ? 3168
Lines ? 109517
Branches ? 19639
================================================
Hits ? 77448
Misses ? 30031
Partials ? 2038
Flags with carried forward coverage won't be shown. Click here to find out more. 🚀 New features to boost your workflow:
|
Backport of #40501