I'm trying out the javascript backend and `pants t...
# general
s
I'm trying out the javascript backend and
pants tailor
adds
Copy code
javascript_sources(
    name="jupytil0",
)

package_json(
    name="jupytil1",
)
but then
pants update-build-files
gives me
KeyError: 'name'
. Removing those targets fixes the issue
w
What version of pants are you on?
s
2.20
w
That's ....... weird
Was the keyerror on the javascript soruces or package?
For me, looks like it shows up on the
package.json
Hmm, maybe for javascript_sources too - getting some weird red herrings 🙂 Okay, no, looks like just package_json for me... I feel like
package_json
should have a name if we want though, so that's weird
s
Hmm... I can't reproduce this in a minimal example.
I must be missing something
w
I seem to be able to repro it in a random build file but only on
package_json
having a name
s
ah you're right. If I delete my
package.json
it goes away
ok lol
so if package.json is missing a name you get ``KeyError: 'name'``
This is really just an instance of pants error messages being cryptic
w
Yeah, wait a sec - that's a Python error from the content of a package.json - 🤯
Can you open a ticket for that? If nothing else, just better logging around that error - as I'm guessing that in our nodejs backend, we use that name for the target name by default. But, I put in a name explicitly, and it still bombed out
Unfortunately, I don't use the JS backend yet, as we don't support TS (which is all I use) - so other than linters/formatters, I don't run into to many of these errors
s
Would this be a bug report?
or a feature request for more helpful error edit this seems more appropriate I guess
b
Bad diagnostics seem like a bug to me (but also doesn't matter too much: having an issue filed at all is the important thing 😄 thank you!)
s
No problem! I forgot about
--print-stacktrace
. I'll keep that in the repertoire.
w
Yeah, in this case, it was (unsurprisingly) in the
package_json.py
under the parser: https://github.com/pantsbuild/pants/blob/954f57b2d78462fd9c687662924dd3616972410f/src/python/pants/backend/javascript/package_json.py#L688 The surprising part is that
name
is optional in package.json files Edit: It's not surprising that
name
is optional, rather that we use an optional key in Pants