laskoviymishka commented on code in PR #2742:
URL: https://github.com/apache/iceberg-go/pull/2742#discussion_r4727501878


##########
io/registry.go:
##########
@@ -190,5 +190,13 @@ func (r *Registry) inferFileIOFromScheme(ctx 
context.Context, path string, props
                return nil, fmt.Errorf("%w for path %q (scheme: %s)", 
ErrIOSchemeNotFound, path, parsed.Scheme)
        }
 
-       return factory(ctx, parsed, props)
+       iofs, err := factory(ctx, parsed, props)
+       if err != nil {
+               return nil, err
+       }
+       if iofs == nil {
+               return nil, fmt.Errorf("io: factory for scheme %q returned nil 
FileIO", parsed.Scheme)

Review Comment:
   Could this wrap a sentinel, the way `ErrIOSchemeNotFound` is wrapped a few 
lines up? Right now callers can only match it by message text, which is why the 
test needs `require.ErrorContains`. Something like:
   
   ```go
   var ErrNilFileIO = errors.New("scheme factory returned nil FileIO")
   
   return nil, fmt.Errorf("%w for scheme %q", ErrNilFileIO, parsed.Scheme)
   ```
   
   and the test can switch to `require.ErrorIs`.



##########
io/io.go:
##########
@@ -406,10 +406,6 @@ func (r *Registry) LoadFS(ctx context.Context, props 
map[string]string, location
                return nil, err
        }
 
-       if iofs == nil {
-               iofs = LocalFS{}
-       }
-
        return iofs, nil

Review Comment:
   With the fallback gone, the tail here reduces to `return 
r.inferFileIOFromScheme(ctx, location, props)`.



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to