Skip to content

Conversation

@jnywong
Copy link
Contributor

@jnywong jnywong commented Dec 5, 2025

This PR adds a button to copy to clipboard the error log from the terminal output.

nbgitpuller-copy-error.mp4

Closes 2i2c-org/infrastructure#7083

More specific and user-friendly error responses for the top 3 failure modes to follow in a separate PR (as part of 2i2c-org/infrastructure#7085), which will rely less on the terminal window/traceback logs.

@jnywong
Copy link
Contributor Author

jnywong commented Dec 5, 2025

Cc @balajialg

@balajialg
Copy link

@jnywong That's great, Thank you!

const button = this.copyError;
button.onclick = async () => {
try {
await navigator.clipboard.writeText(errorText);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thinking about what other thing would be useful, can you also copy the nbgitpuller URL itself? that contains important and helpful info about the repo and branch that I think help a lot. But let's just copy the url - base_url (so just /git-sync?query-params) so we don't automatically include the username here, as that could be PII.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for the suggestion.

Had a look at the query params used in the GitSync class

  this.baseUrl = baseUrl;
  this.repo = repo;
  this.branch = branch;
  this.depth = depth; // not currently used because of shallow clone https://github.com/jupyterhub/nbgitpuller/pull/117
  this.targetpath = targetpath; // optional folder to clone into
  this.redirectUrl = baseUrl + path;
  this._xsrf = xsrf;

and pulled out repo, branch and redirectUrl to insert into the error text. Now the terminal output prints this info in addition to the traceback log, that can be copied to clipboard:

Repository: https://github.com/data-8/textbook
Branch: gh-pages
Redirect URL: /tree/textbook/.

Traceback (most recent call last):
File "/Users/jnywong/Documents/github/nbgitpuller/nbgitpuller/handlers.py", line 87, in get
    gp = GitPuller(repo, repo_dir, branch=branch, depth=depth, parent=self.settings['nbapp'])
File "/Users/jnywong/Documents/github/nbgitpuller/nbgitpuller/pull.py", line 81, in __init__
    raise ValueError(f"Branch: {self.branch_name} -- not found in repo: {self.git_url}")
ValueError: Branch: gh-pages -- not found in repo: https://github.com/data-8/textbook
Screenshot 2025-12-08 at 12 06 29

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

Status: No status

Development

Successfully merging this pull request may close these issues.

Redesign nbgitpuller error handling response for link-consumers

3 participants