Skip to content

Improve diagnostics for the case of missing tag name in #enddocfragment #5

@alexander-yevsyukov

Description

@alexander-yevsyukov

I forgot to put a tag name after #enddocfragment and got this:

> Task :docs:embedCode FAILED
Using user's local bash profile.
export plugin already enabled
2026/02/16 17:51:17 INFO starting application, reading args...
panic: runtime error: slice bounds out of range [23:22]

goroutine 1 [running]:
embed-code/embed-code-go/fragmentation.lookup({0x14000d25b60, 0x16}, {0x100fad0c3, 0xf})
        /Users/vladyslav.kuksiuk/Desktop/Work/embed-code/embed-code-go/fragmentation/lookup.go:71 +0x1b0
embed-code/embed-code-go/fragmentation.FindEndDocFragments(...)
        /Users/vladyslav.kuksiuk/Desktop/Work/embed-code/embed-code-go/fragmentation/lookup.go:53
embed-code/embed-code-go/fragmentation.Fragmentation.parseLine({{{0x1400000e810, 0x8}, {0x1400000e830, 0x10}, {0x10111e6c0, 0x1, 0x1}, {0x10111fc40, 0x2, 0x2}, ...}, ...}, ...)
        /Users/vladyslav.kuksiuk/Desktop/Work/embed-code/embed-code-go/fragmentation/fragmentation.go:242 +0x70
embed-code/embed-code-go/fragmentation.Fragmentation.DoFragmentation({{{0x1400000e810, 0x8}, {0x1400000e830, 0x10}, {0x10111e6c0, 0x1, 0x1}, {0x10111fc40, 0x2, 0x2}, ...}, ...})
        /Users/vladyslav.kuksiuk/Desktop/Work/embed-code/embed-code-go/fragmentation/fragmentation.go:115 +0x14c
embed-code/embed-code-go/fragmentation.Fragmentation.WriteFragments({{{0x1400000e810, 0x8}, {0x1400000e830, 0x10}, {0x10111e6c0, 0x1, 0x1}, {0x10111fc40, 0x2, 0x2}, ...}, ...})
        /Users/vladyslav.kuksiuk/Desktop/Work/embed-code/embed-code-go/fragmentation/fragmentation.go:137 +0x40
embed-code/embed-code-go/fragmentation.writeFragments({{0x1400000e810, 0x8}, {0x1400000e830, 0x10}, {0x10111e6c0, 0x1, 0x1}, {0x10111fc40, 0x2, 0x2}, ...}, ...)
        /Users/vladyslav.kuksiuk/Desktop/Work/embed-code/embed-code-go/fragmentation/fragmentation.go:204 +0x9c
embed-code/embed-code-go/fragmentation.WriteFragmentFiles({{0x1400000e810, 0x8}, {0x1400000e830, 0x10}, {0x10111e6c0, 0x1, 0x1}, {0x10111fc40, 0x2, 0x2}, ...})
        /Users/vladyslav.kuksiuk/Desktop/Work/embed-code/embed-code-go/fragmentation/fragmentation.go:177 +0x15c
embed-code/embed-code-go/cli.EmbedCodeSamples({{0x1400000e810, 0x8}, {0x1400000e830, 0x10}, {0x10111e6c0, 0x1, 0x1}, {0x10111fc40, 0x2, 0x2}, ...})
        /Users/vladyslav.kuksiuk/Desktop/Work/embed-code/embed-code-go/cli/cli.go:107 +0x44
main.main()
        /Users/vladyslav.kuksiuk/Desktop/Work/embed-code/embed-code-go/main.go:111 +0x48c

[Incubating] Problems report is available at: file:///Users/sanders/Projects/Spine/validation/build/reports/problems/problems-report.html

FAILURE: Build failed with an exception.

* What went wrong:
Execution failed for task ':docs:embedCode'.
> Process 'command '/Users/sanders/Projects/Spine/validation/docs/_script/embed-code'' finished with non-zero exit value 2

It took some time to figure out the cause.

It's natural to assume that the tag name is not needed because it resembles closing braces.
Yes, of course, there is a case of overlapping fragments and it is why we require the name of the fragment in the closing tag.

It would be helpful to have a meaningful error message which points out the absence of the name of the tag.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions