Compare commits

...

3 Commits

Author SHA1 Message Date
Hein
0d50bcfee6 fix(provider): enhance file opening logic with alternate path. Handling broken cases to be compatible with Bitech clients
* Implemented alternate path handling for file retrieval
* Improved error messaging for file not found scenarios
2026-03-24 09:02:17 +02:00
4df626ea71 chore(license): update project notice and clarify licensing terms 2026-03-23 20:32:09 +02:00
Hein
7dd630dec2 fix(handler): set default sort to primary key if none provided
Some checks failed
Build , Vet Test, and Lint / Run Vet Tests (1.24.x) (push) Successful in -26m15s
Build , Vet Test, and Lint / Run Vet Tests (1.23.x) (push) Successful in -26m11s
Build , Vet Test, and Lint / Lint Code (push) Failing after -30m52s
Build , Vet Test, and Lint / Build (push) Successful in -30m44s
Tests / Integration Tests (push) Failing after -31m5s
Tests / Unit Tests (push) Successful in -29m6s
2026-03-11 14:37:04 +02:00
6 changed files with 78 additions and 9 deletions

15
LICENSE
View File

@@ -1,3 +1,18 @@
Project Notice
This project was independently developed.
The contents of this repository were prepared and published outside any time
allocated to Bitech Systems CC and do not contain, incorporate, disclose,
or rely upon any proprietary or confidential information, trade secrets,
protected designs, or other intellectual property of Bitech Systems CC.
No portion of this repository reproduces any Bitech Systems CC-specific
implementation, design asset, confidential workflow, or non-public technical material.
This notice is provided for clarification only and does not modify the terms of
the Apache License, Version 2.0.
Apache License Apache License
Version 2.0, January 2004 Version 2.0, January 2004
http://www.apache.org/licenses/ http://www.apache.org/licenses/

View File

@@ -329,6 +329,11 @@ func (h *Handler) handleRead(ctx context.Context, w common.ResponseWriter, id st
// Extract model columns for validation // Extract model columns for validation
modelColumns := reflection.GetModelColumns(model) modelColumns := reflection.GetModelColumns(model)
// Default sort to primary key when none provided
if len(options.Sort) == 0 {
options.Sort = []common.SortOption{{Column: pkName, Direction: "ASC"}}
}
// Get cursor filter SQL // Get cursor filter SQL
cursorFilter, err := GetCursorFilter(tableName, pkName, modelColumns, options) cursorFilter, err := GetCursorFilter(tableName, pkName, modelColumns, options)
if err != nil { if err != nil {

View File

@@ -731,6 +731,11 @@ func (h *Handler) handleRead(ctx context.Context, w common.ResponseWriter, id st
// For now, pass empty map as joins are handled via Preload // For now, pass empty map as joins are handled via Preload
} }
// Default sort to primary key when none provided
if len(options.Sort) == 0 {
options.Sort = []common.SortOption{{Column: pkName, Direction: "ASC"}}
}
// Get cursor filter SQL // Get cursor filter SQL
cursorFilter, err := options.GetCursorFilter(tableName, pkName, modelColumns, expandJoins) cursorFilter, err := options.GetCursorFilter(tableName, pkName, modelColumns, expandJoins)
if err != nil { if err != nil {

View File

@@ -98,6 +98,7 @@ func (p *EmbedFSProvider) Open(name string) (fs.File, error) {
// Apply prefix stripping by prepending the prefix to the requested path // Apply prefix stripping by prepending the prefix to the requested path
actualPath := name actualPath := name
alternatePath := ""
if p.stripPrefix != "" { if p.stripPrefix != "" {
// Clean the paths to handle leading/trailing slashes // Clean the paths to handle leading/trailing slashes
prefix := strings.Trim(p.stripPrefix, "/") prefix := strings.Trim(p.stripPrefix, "/")
@@ -105,12 +106,25 @@ func (p *EmbedFSProvider) Open(name string) (fs.File, error) {
if prefix != "" { if prefix != "" {
actualPath = path.Join(prefix, cleanName) actualPath = path.Join(prefix, cleanName)
alternatePath = cleanName
} else { } else {
actualPath = cleanName actualPath = cleanName
} }
} }
// First try the actual path with prefix
if file, err := p.fs.Open(actualPath); err == nil {
return file, nil
}
return p.fs.Open(actualPath) // If alternate path is different, try it as well
if alternatePath != "" && alternatePath != actualPath {
if file, err := p.fs.Open(alternatePath); err == nil {
return file, nil
}
}
// If both attempts fail, return the error from the first attempt
return nil, fmt.Errorf("file not found: %s", name)
} }
// Close releases any resources held by the provider. // Close releases any resources held by the provider.

View File

@@ -53,6 +53,7 @@ func (p *LocalFSProvider) Open(name string) (fs.File, error) {
// Apply prefix stripping by prepending the prefix to the requested path // Apply prefix stripping by prepending the prefix to the requested path
actualPath := name actualPath := name
alternatePath := ""
if p.stripPrefix != "" { if p.stripPrefix != "" {
// Clean the paths to handle leading/trailing slashes // Clean the paths to handle leading/trailing slashes
prefix := strings.Trim(p.stripPrefix, "/") prefix := strings.Trim(p.stripPrefix, "/")
@@ -60,12 +61,26 @@ func (p *LocalFSProvider) Open(name string) (fs.File, error) {
if prefix != "" { if prefix != "" {
actualPath = path.Join(prefix, cleanName) actualPath = path.Join(prefix, cleanName)
alternatePath = cleanName
} else { } else {
actualPath = cleanName actualPath = cleanName
} }
} }
return p.fs.Open(actualPath) // First try the actual path with prefix
if file, err := p.fs.Open(actualPath); err == nil {
return file, nil
}
// If alternate path is different, try it as well
if alternatePath != "" && alternatePath != actualPath {
if file, err := p.fs.Open(alternatePath); err == nil {
return file, nil
}
}
// If both attempts fail, return the error from the first attempt
return nil, fmt.Errorf("file not found: %s", name)
} }
// Close releases any resources held by the provider. // Close releases any resources held by the provider.

View File

@@ -56,6 +56,7 @@ func (p *ZipFSProvider) Open(name string) (fs.File, error) {
// Apply prefix stripping by prepending the prefix to the requested path // Apply prefix stripping by prepending the prefix to the requested path
actualPath := name actualPath := name
alternatePath := ""
if p.stripPrefix != "" { if p.stripPrefix != "" {
// Clean the paths to handle leading/trailing slashes // Clean the paths to handle leading/trailing slashes
prefix := strings.Trim(p.stripPrefix, "/") prefix := strings.Trim(p.stripPrefix, "/")
@@ -63,12 +64,26 @@ func (p *ZipFSProvider) Open(name string) (fs.File, error) {
if prefix != "" { if prefix != "" {
actualPath = path.Join(prefix, cleanName) actualPath = path.Join(prefix, cleanName)
alternatePath = cleanName
} else { } else {
actualPath = cleanName actualPath = cleanName
} }
} }
return p.zipFS.Open(actualPath) // First try the actual path with prefix
if file, err := p.zipFS.Open(actualPath); err == nil {
return file, nil
}
// If alternate path is different, try it as well
if alternatePath != "" && alternatePath != actualPath {
if file, err := p.zipFS.Open(alternatePath); err == nil {
return file, nil
}
}
// If both attempts fail, return the error from the first attempt
return nil, fmt.Errorf("file not found: %s", name)
} }
// Close releases resources held by the zip reader. // Close releases resources held by the zip reader.