Skip to content
This repository was archived by the owner on Apr 3, 2024. It is now read-only.

Commit 007cbbd

Browse files
authored
fix: correctly send labels on register calls. (#1118)
Debuggee labels were not being sent to the firebase rtdb when registering. This resulted in debuggees without adequate information to identify them using the snapshot debugger cli. There was no functional difference otherwise.
1 parent a188e34 commit 007cbbd

File tree

2 files changed

+35
-1
lines changed

2 files changed

+35
-1
lines changed

src/agent/firebase-controller.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -169,7 +169,7 @@ export class FirebaseController implements Controller {
169169
debuggee.id = this.debuggeeId;
170170

171171
const debuggeeRef = this.db.ref(`cdbg/debuggees/${this.debuggeeId}`);
172-
debuggeeRef.set(debuggee, err => {
172+
debuggeeRef.set(debuggee as {}, err => {
173173
if (err) {
174174
callback(err);
175175
} else {

test/test-firebase-controller.ts

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -183,6 +183,40 @@ describe('Firebase Controller', () => {
183183
done();
184184
});
185185
});
186+
it('should pass labels properly', done => {
187+
const db = new MockDatabase();
188+
// Debuggee Id is based on the sha1 hash of the json representation of
189+
// the debuggee.
190+
const debuggeeId = 'd-cbd029da';
191+
const debuggeeWithLabels = new Debuggee({
192+
project: 'fake-project',
193+
uniquifier: 'fake-id',
194+
description: 'unit test',
195+
agentVersion: 'SomeName/client/SomeVersion',
196+
labels: {
197+
V8_version: 'v8_version',
198+
process_title: 'node',
199+
projectid: 'fake-project',
200+
agent_version: '7.x',
201+
version: 'appengine_version',
202+
minorversion: 'minor_version',
203+
},
204+
});
205+
206+
const controller = new FirebaseController(
207+
db as {} as firebase.database.Database
208+
);
209+
controller.register(debuggeeWithLabels, (err, result) => {
210+
assert(!err, 'not expecting an error');
211+
assert.ok(result);
212+
assert.strictEqual(result!.debuggee.id, debuggeeId);
213+
assert.strictEqual(
214+
db.mockRef(`cdbg/debuggees/${debuggeeId}`).value,
215+
debuggeeWithLabels
216+
);
217+
done();
218+
});
219+
});
186220
it('should error out gracefully', done => {
187221
const db = new MockDatabase();
188222
// Debuggee Id is based on the sha1 hash of the json representation of

0 commit comments

Comments
 (0)