Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Unable to share errors if class/method name is not resolved in the stack trace #214

Open
tibbsa opened this issue Dec 9, 2024 · 0 comments

Comments

@tibbsa
Copy link

tibbsa commented Dec 9, 2024

Working with the Statamic CMS, I have a situation where an exception is being thrown in the context of rendering an antler tag. The problem is that the stack trace (in part) begins like this:

[object] (Spatie\LaravelIgnition\Exceptions\ViewException(code: 0): Cannot access offset of type Statamic\Sites\Site in isset or empty at ~\resources\views/categories/index.antlers.html:5)
[stacktrace]
#0 ~\resources\views/categories/index.antlers.html(5): ()
#1 ~\vendor\statamic\cms\src\Taxonomies\Term.php(281): Illuminate\Support\Collection->offsetExists(Object(Statamic\Sites\Site))
#2 ~\vendor\statamic\cms\src\Taxonomies\LocalizedTerm.php(77): Statamic\Taxonomies\Term->dataForLocale(Object(Statamic\Sites\Site))
#3 ~\vendor\statamic\cms\src\Taxonomies\LocalizedTerm.php(96): Statamic\Taxonomies\LocalizedTerm->data()
#4 ~\vendor\statamic\cms\src\Taxonomies\AugmentedTerm.php(21): Statamic\Taxonomies\LocalizedTerm->values()

Note, in particular, the first frame of the stack trace. No method name was resolved from the template. Ergo, when I try to 'share' the stack trace, the below is sent as the first item in the report.stacktrace field:

{
    "file": "(...)\\resources\\views/categories/index.antlers.html",
    "line_number": 5,
    "method": null,
    "class": null,
    "code_snippet": {
        "1": "<div class=\"container py-8 md:py-12\">",
        "2": "    {{ partial:components/heading size=\"h2\" :label=\"title\" center=\"true\" }}",
        "3": "    {{ if categories }}",
        "4": "        <ul class=\"flex flex-wrap items-center justify-center mt-12\">",
        "5": "            {{ categories }}",
        "6": "                <li class=\"mb-6 mr-6\">",
        "7": "                    <a href=\"{{ url }}\" aria-label=\"{{ title }}\"",
        "8": "                        class=\"px-3 py-2 text-sm font-medium text-gray-500 transition-all border rounded-md hover:bg-indigo-100 hover:text-blue-500 hover:border-transparent\">",
        "9": "                        {{ title }}",
        "10": "                    </a>",
        "11": "                </li>",
        "12": "            {{ /categories }}",
        "13": "        </ul>",
        "14": "    {{ else }}",
        "15": "        <p class=\"flex items-center justify-center mt-12\">",
        "16": "            There are no categories.",
        "17": "        </p>",
        "18": "    {{ /if }}",
        "19": "</div>",
        "20": ""
    },
    "arguments": [],
    "application_frame": true
}

The sharing API rejects this:

{
    "message": "The stacktrace.0.method field is required.",
    "errors": {
        "stacktrace.0.method": [
            "The stacktrace.0.method field is required."
        ]
    }
}

This validation appears to be too strict?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant