build-your-own-git icon indicating copy to clipboard operation
build-your-own-git copied to clipboard

Tester says "internal error" on stage 5 for a user error

Open rohitpaulk opened this issue 1 year ago • 1 comments
trafficstars

Logs:

Dec 19 12:49:00 148e5315b37068 vector [stage-5] Creating some files & directories
Dec 19 12:49:00 148e5315b37068 vector [stage-5] $ ./your_git.sh write-tree
Dec 19 12:49:00 148e5315b37068 vector [your_program] aec2d24a22463ac63c7ec9684903f7f5ba292c79
Dec 19 12:49:00 148e5315b37068 vector [stage-5] Reading file at .git/objects/ae/c2d24a22463ac63c7ec9684903f7f5ba292c79
Dec 19 12:49:00 148e5315b37068 vector Error [stage-5] CodeCrafters internal error. Error reading .git/objects/ae/c2d24a22463ac63c7ec9684903f7f5ba292c79: open /tmp/worktree814524593/.git/objects/ae/c2d24a22463ac63c7ec9684903f7f5ba292c79: no such file or directory
Dec 19 12:49:00 148e5315b37068 vector [stage-5] Test failed

Here's our code that's supposed to filter user vs. internal error:

	if err == os.ErrNotExist {
		return fmt.Errorf("Did you write the tree object? Did not find a file in .git/objects/<first 2 chars of sha>/<remaining chars of sha>")
	} else if err != nil {
		return fmt.Errorf("CodeCrafters internal error. Error reading %v: %v", relativePath, err)
	}

Looks like this specific instance of "no such file or directory" isn't covered by os.ErrNotExist?

rohitpaulk avatar Dec 19 '23 12:12 rohitpaulk

Relevant ChatGPT convo: https://chat.openai.com/share/a8e0acc3-2a33-4e00-bc04-4ef8962c9673

Looks like we should use errors.Is instead?

rohitpaulk avatar Dec 19 '23 12:12 rohitpaulk