src-cli
src-cli copied to clipboard
src extension publish errors with unclear action to take
I just tried to publish an extension and just got an unhelpful JSON dump of a GraphQL error:
GraphQL errors:
[
{
"message": "registry extension publisher not found: [name felixfbecker]",
"path": [
"extensionRegistry",
"publishExtension"
]
}
]
I don't know how to resolve this, and I think the JSON dumping is a bit lazy. Since GraphQL errors have a known schema, we can pretty print these errors, otherwise as a user I get the impression that I ran into an unexpected bug instead of an expected condition that I can resolve.
As an inspiration, I think PSSourcegraph does a slightly better job here:
✔ ~/src/github.com/sourcegraph/enterprise [master ≡]
> Search-Sourcegraph 'foo:bar'
Invoke-SourcegraphApiRequest : type error at character 0: unrecognized field "foo"
At search
At /Users/felix/.local/share/powershell/Modules/PSSourcegraph/0.0.5/src/search.psm1:24 char:13
+ $data = Invoke-SourcegraphApiRequest -Query $SearchQuery -Variabl ...
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : NotSpecified: (:) [Write-Error], Exception
+ FullyQualifiedErrorId : System.Exception,Invoke-SourcegraphApiRequest
✔ ~/src/github.com/sourcegraph/enterprise [master ≡]
> Enable-SourcegraphRepository -Id 'askdjaslkdasdasd'
Invoke-SourcegraphApiRequest : invalid graphql.ID
At setRepositoryEnabled
At /Users/felix/.local/share/powershell/Modules/PSSourcegraph/0.0.5/src/repos.psm1:58 char:5
+ Invoke-SourcegraphApiRequest -Query $setRepositoryEnabledQuery -V ...
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : NotSpecified: (:) [Write-Error], Exception
+ FullyQualifiedErrorId : System.Exception,Invoke-SourcegraphApiRequest
Note how the GraphQL error message gets used as the exception message and the path is used to provide a dot-joined trace at what field the error occurred.
You first have to create the extension using the web interface - https://sourcegraph.com/extensions/registry/new
After that you can src extensions publish.
The problem appears to be that there was no user or org named felixfbecker. I have a PR https://github.com/sourcegraph/sourcegraph/pull/2828 that improves the error message. I also opened https://github.com/sourcegraph/src-cli/issues/39 to address the general issue of printing error messages in a nicer way.
@TobiaszCudnik: Thank you for posting! You actually can just run src extensions publish and it will create it. Your steps are helpful because running through them is likely to make the user aware of the problem, but I hope the PR above removes this confusion altogether.
Hey @sqs, I’ll reopen because the primary improvement I was asking for here was to format the error instead of dumping JSON (see description for reasoning)
@felixfbecker I moved that to https://github.com/sourcegraph/src-cli/issues/39. Can I close this? 😃
Extensions have been deprected, so I am going to close this ticket as part of some backlog grooming. Please reopen if you think we should still care about it.