Skip to content

Commit b046c39

Browse files
authored
Merge pull request #3712 from jsternberg/dap-skip-context-without-source
dap: skip the load build context step when it doesn't have an associated source line
2 parents 9e31c0f + 3e4bd22 commit b046c39

2 files changed

Lines changed: 14 additions & 49 deletions

File tree

dap/thread.go

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -180,6 +180,12 @@ func (t *thread) createBranch(dgst digest.Digest, exitpoint *step) (entrypoint *
180180
parent: -1,
181181
}
182182

183+
// The entrypoint doesn't have a source entry. Just skip this
184+
// branch.
185+
if entrypoint.frame.Source == nil {
186+
return nil
187+
}
188+
183189
// Create a pseudo-frame and attach it to the return point.
184190
// This is mostly used for getting the correct inputs utilized
185191
// by this frame.
@@ -223,11 +229,18 @@ func (t *thread) createBranch(dgst digest.Digest, exitpoint *step) (entrypoint *
223229
inp := op.Inputs[i]
224230

225231
head := *entrypoint
226-
entrypoint.dgst = ""
227232

228233
// Create the routine associated with this input.
229234
// Associate it with the entrypoint in step.
230235
head.in = t.createBranch(digest.Digest(inp.Digest), entrypoint)
236+
237+
// If this branch is empty (signified by a nil return value) then
238+
// skip it.
239+
if head.in == nil {
240+
continue
241+
}
242+
243+
entrypoint.dgst = ""
231244
entrypoint = &head
232245
}
233246

tests/dap_build.go

Lines changed: 0 additions & 48 deletions
Original file line numberDiff line numberDiff line change
@@ -406,54 +406,6 @@ func testDapBuildStepIn(t *testing.T, sb integration.Sandbox) {
406406
Name: `^\[stage-1 .*\] COPY .* /etc/bar`,
407407
},
408408
},
409-
// the following three steps are unintended and are the result
410-
// of a bug in the debug adapter.
411-
// see issue https://github.com/docker/buildx/issues/3565
412-
{
413-
{
414-
Name: `^\[internal\] load build context`,
415-
},
416-
{
417-
SourceName: "Dockerfile",
418-
Line: 3,
419-
Name: `^\[base .*\] COPY foo`,
420-
},
421-
{
422-
SourceName: "Dockerfile",
423-
Line: 7,
424-
Name: `^\[stage-1 .*\] COPY .* /etc/bar`,
425-
},
426-
},
427-
// todo: this shouldn't be a stop point.
428-
{
429-
{
430-
Name: `^\[internal\] load build context`,
431-
},
432-
{
433-
SourceName: "Dockerfile",
434-
Line: 3,
435-
Name: `^\[base .*\] COPY foo`,
436-
},
437-
{
438-
SourceName: "Dockerfile",
439-
Line: 7,
440-
Name: `^\[stage-1 .*\] COPY .* /etc/bar`,
441-
},
442-
},
443-
// duplicate of stop point 3 because of unintended branch
444-
// associated with the build context copy.
445-
{
446-
{
447-
SourceName: "Dockerfile",
448-
Line: 3,
449-
Name: `^\[base .*\] COPY foo`,
450-
},
451-
{
452-
SourceName: "Dockerfile",
453-
Line: 7,
454-
Name: `^\[stage-1 .*\] COPY .* /etc/bar`,
455-
},
456-
},
457409
// stop point 4
458410
{
459411
{

0 commit comments

Comments
 (0)