Skip to content
This repository was archived by the owner on May 14, 2025. It is now read-only.

Commit 67a358e

Browse files
committed
Ensure recognize tap streams when computing text from graph
Without this change if the first stream in a graph is a tap stream the graph to text algorithm will make a mistake and not treat it as a tap stream because Array.find returns 0 in this case (because it is stream 0 that is a tap stream). 0 is treated as false. It is better to check the Array.find call returned a result (i.e. result is not undefined) Fixes #603
1 parent 2827211 commit 67a358e

File tree

2 files changed

+11
-1
lines changed

2 files changed

+11
-1
lines changed

ui/src/app/streams/flo/graph-to-text.spec.ts

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -398,6 +398,16 @@ describe('graph-to-text', () => {
398398
expect(dsl).toEqual('aaa=time | logA\n:aaa.time > logB');
399399
});
400400

401+
it('tapped simple stream 2', () => {
402+
const timeSource = createSource('time');
403+
timeSource.attr('stream-name', 'aaa');
404+
// Now the tap is the first one, not the second one
405+
createTap(timeSource, createSink('logA'));
406+
createLink(timeSource, createSink('logB'));
407+
dsl = convertGraphToText(graph);
408+
expect(dsl).toEqual(':aaa.time > logA\naaa=time | logB');
409+
});
410+
401411
it('tap into processor', () => {
402412
const timeSource = createSource('time');
403413
timeSource.attr('stream-name', 'aaa');

ui/src/app/streams/flo/graph-to-text.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -186,7 +186,7 @@ class GraphToTextConverter {
186186

187187
for (let i = 0; i < stream.length; i++) {
188188
const node = stream[i];
189-
const isTapStream = tapStreams.find(ts => ts === s);
189+
const isTapStream = typeof tapStreams.find(ts => ts === s) !== 'undefined';
190190
if (i === 0) { // If first node, special handling...
191191
// For a tap the name is on the 2nd element
192192
const nameIndex = (isTapStream || this.isChannel(node)) ? 1 : 0;

0 commit comments

Comments
 (0)