optic: [Bug] Invalid object name 'C' when running optic diff
Hi,
I’m running into an odd issue with the diff command, I’m hoping someone here can provide some guidance.
I’m following the guide Try the optic diff command, the command is successful if I compare two files in the same branch as demoed in Two files use case but when I run the diff command showned below across two different git branches I get an error stating that the object name ‘C’ is invalid.
The following command.
optic diff todo-api.yaml --base main
Results in the following error.
{
stack: 'ResolverError: Command failed: git show C:Users\\circleupx\\source\\openapi-demo\\todo-api.yaml\n' +
"fatal: invalid object name 'C'.\n" +
' Error opening file "Users\\circleupx\\source\\openapi-demo\\todo-api.yaml"\n' +
' at C:\\Users\\circleupx\\AppData\\Roaming\\npm\\node_modules\\@useoptic\\optic\\node_modules\\@useoptic\\openapi-io\\build\\parser\\resolvers\\git-branch-file-resolver.js:24:32\n' +
' at ChildProcess.exithandler (node:child_process:406:5)\n' +
' at ChildProcess.emit (node:events:520:28)\n' +
' at ChildProcess.emit (node:domain:475:12)\n' +
' at maybeClose (node:internal/child_process:1092:16)\n' +
' at Process.ChildProcess._handle.onexit (node:internal/child_process:302:5)',
code: 'ERESOLVER',
message: 'Command failed: git show C:Users\\circleupx\\source\\openapi-demo\\todo-api.yaml\n' +
"fatal: invalid object name 'C'.\n" +
' Error opening file "Users\\circleupx\\source\\openapi-demo\\todo-api.yaml"',
source: 'Users\\circleupx\\source\\openapi-demo\\todo-api.yaml',
path: null,
toJSON: [Function: toJSON],
name: 'ResolverError',
footprint: 'null+Users\\circleupx\\source\\openapi-demo\\todo-api.yaml+ERESOLVER+Command failed: git show C:Users\\circleupx\\source\\openapi-demo\\todo-api.yaml\n' +
"fatal: invalid object name 'C'.\n" +
' Error opening file "Users\\circleupx\\source\\openapi-demo\\todo-api.yaml"',
toString: [Function: toString]
}
Doing some troubleshooting led me to the git-branch-file-resolver.js where I can see that the code is attempting to execute the command git show.
Based on my knowledge of the command git show, if you want to run git show on the same file across two different branches then you need to include the branch name in the git show command.
For example, currently, the optic CLI is attempting to execute the following command when I execute optic diff todo-api.yaml --base main
git show C:Users\\circleupx\\source\\openapi-demo\\todo-api.yaml'
The command above should really be as follows.
git show main:C\\Users\\circleupx\\source\\openapi-demo\\todo-api.yaml'
If update the git-branch-file-resolver.js file locally then I no longer the error “the object name ‘C’ is invalid”.
I’m running Optic version 0.35.4.
Thank you.
About this issue
- Original URL
- State: closed
- Created 2 years ago
- Comments: 16 (9 by maintainers)
@acunniffe No, that is all, thank you so much for all the help.
I won’t be able to test until this upcoming Friday. Thanks for the explanation it helps me understand Optic better
Hi,
Yes, I tried it in WIndow’s bash and on Powershell, and both shells gave me the same error.
Here is some information on my build and shell.
Here is the output of the command systeminfo | findstr /B /C:“OS Name” /C:“OS Version”
As previously stated, I’m on Optic 0.35.4.
For bash, here is the output of bash --version
For Powershell here is the output of $PSVersionTable
I can confirm that the command works in WSL. I will continue my work on WSL for now.
Here is my output of WSL -V
Let me know if you need additional information.