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)

Most upvoted comments

@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”

OS Name:  Microsoft Windows 11 Home
OS Version:   10.0.22621 N/A Build 22621

As previously stated, I’m on Optic 0.35.4.

For bash, here is the output of bash --version

GNU bash, version 4.4.23(1)-release (x86_64-pc-msys)
Copyright (C) 2016 Free Software Foundation, Inc.
License GPLv3+: GNU GPL version 3 or later <http://gnu.org/licenses/gpl.html>

This is free software; you are free to change and redistribute it.
There is NO WARRANTY, to the extent permitted by law.

For Powershell here is the output of $PSVersionTable

Name                           Value
----                           -----
PSVersion                      5.1.22621.608
PSEdition                      Desktop
PSCompatibleVersions           {1.0, 2.0, 3.0, 4.0...}
BuildVersion                   10.0.22621.608
CLRVersion                     4.0.30319.42000
WSManStackVersion              3.0
PSRemotingProtocolVersion      2.3
SerializationVersion           1.1.0.1

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

WSL version: 1.0.0.0
Kernel version: 5.15.74.2
WSLg version: 1.0.47
MSRDC version: 1.2.3575
Direct3D version: 1.606.4
DXCore version: 10.0.25131.1002-220531-1700.rs-onecore-base2-hyp
Windows version: 10.0.22621.819

Let me know if you need additional information.