Repository navigation
Issues noticed while dockerizing the bq connection to flapi - #1
Merged
Merged
Conversation
Collaborator
Author
|
Thanks for checking but I still face the following errors : Issue 1 : Sub directories are not scanned properly for SQL files to cacheI believe it is not scanning the recommendations folder for SQL files ? Issue 2 : Empty server response from server |
jrosskopf
self-requested a review
October 31, 2024 12:56
jrosskopf
approved these changes
Oct 31, 2024
This was referenced May 21, 2026
jrosskopf
added a commit
that referenced
this pull request
May 22, 2026
Part of #40. Implements integration tests for the spike's documented round-trip behaviours, plus a fix surfaced by the tests. New file: test/integration/test_self_packaging.py (8 tests, ~24 sec wall on Linux x86_64 debug build): #2 pack_produces_bundled_executable `flapi pack --in <fixture> --out <new>` succeeds, output exists, exec bits preserved (Unix), file size >= host binary size. #4 info_reports_bundle_contents `<bundled> info` shows EOCD offset, bundle size, and lists every fixture entry by name. #5 self_hosting_rebundle The bundled binary can pack a new bundled binary (`<bundled> pack ...`), which itself has a valid bundle. #6 repack_idempotence Three rounds of packing using each previous output as host binary -- file size identical across rounds. #7 truncated_bundle_falls_back_to_filesystem Chop 1 KiB off the tail. `info` reports "none". A `--validate-config -c <fixture>/flapi.yaml` invocation exits cleanly (no SIGSEGV/SIGABRT) -- the spike safety-net behaviour. #8 unpack_restores_all_entries `<bundled> unpack --to <dir>` writes every entry; CSV bytes round-trip byte-for-byte. pack_refuses_secret_files_by_default `.env` in input -> non-zero exit, "secret" in error message, AND no half-written output binary on disk. pack_with_allow_secrets_bundles_env_files --allow-secrets override bundles `.env` despite the deny list; `info` lists it. Implementation fix (src/pack.cpp): `Pack()` previously copied the multi-GB host binary BEFORE walking the input tree and validating the secret deny list. A rejected `.env` therefore left a half-written 1.7 GB file in the user's tmp dir. Re-ordered: walk + validate first, then copy + append. Surfaced by `test_pack_refuses_secret_files_by_default`. Spike behaviours #1, #3, #9 (filesystem-mode + bundled-mode HTTP + read_csv('embed://...') endpoint) require server-lifecycle test infrastructure plus resolving bundled-mode config-path lookup (template.path resolution from inside an `embed://` config) -- deferred to a follow-up issue. The DuckDB-side embed:// integration is already proven in-process by the unit tests in #44. Closes #46 (partial -- server-lifecycle behaviours deferred).
jrosskopf
added a commit
that referenced
this pull request
May 22, 2026
Part of #40. Implements integration tests for the spike's documented round-trip behaviours, plus a fix surfaced by the tests. New file: test/integration/test_self_packaging.py (8 tests, ~24 sec wall on Linux x86_64 debug build): #2 pack_produces_bundled_executable `flapi pack --in <fixture> --out <new>` succeeds, output exists, exec bits preserved (Unix), file size >= host binary size. #4 info_reports_bundle_contents `<bundled> info` shows EOCD offset, bundle size, and lists every fixture entry by name. #5 self_hosting_rebundle The bundled binary can pack a new bundled binary (`<bundled> pack ...`), which itself has a valid bundle. #6 repack_idempotence Three rounds of packing using each previous output as host binary -- file size identical across rounds. #7 truncated_bundle_falls_back_to_filesystem Chop 1 KiB off the tail. `info` reports "none". A `--validate-config -c <fixture>/flapi.yaml` invocation exits cleanly (no SIGSEGV/SIGABRT) -- the spike safety-net behaviour. #8 unpack_restores_all_entries `<bundled> unpack --to <dir>` writes every entry; CSV bytes round-trip byte-for-byte. pack_refuses_secret_files_by_default `.env` in input -> non-zero exit, "secret" in error message, AND no half-written output binary on disk. pack_with_allow_secrets_bundles_env_files --allow-secrets override bundles `.env` despite the deny list; `info` lists it. Implementation fix (src/pack.cpp): `Pack()` previously copied the multi-GB host binary BEFORE walking the input tree and validating the secret deny list. A rejected `.env` therefore left a half-written 1.7 GB file in the user's tmp dir. Re-ordered: walk + validate first, then copy + append. Surfaced by `test_pack_refuses_secret_files_by_default`. Spike behaviours #1, #3, #9 (filesystem-mode + bundled-mode HTTP + read_csv('embed://...') endpoint) require server-lifecycle test infrastructure plus resolving bundled-mode config-path lookup (template.path resolution from inside an `embed://` config) -- deferred to a follow-up issue. The DuckDB-side embed:// integration is already proven in-process by the unit tests in #44. Closes #46 (partial -- server-lifecycle behaviours deferred).
This was referenced May 24, 2026
jrosskopf
added a commit
that referenced
this pull request
May 25, 2026
Before this change, `flapi pack` produced a working binary at the CLI
level (`info`, `unpack`, etc.) but `./flapi-bundled` started from a
clean cwd crashed with "Could not open file: flapi.yaml" -- the
EmbeddedArchiveFileProvider was registered globally but the config /
endpoint / template loaders bypassed it via std::ifstream and
std::filesystem::recursive_directory_iterator.
Four call sites had to be routed through FileProviderFactory so the
in-memory archive is actually consulted when SetBundleContents has
fired:
- extended_yaml_parser: parseFile and the static loadYamlFile now
read via FileProviderFactory::CreateProvider(path)->ReadFile(...)
instead of std::ifstream. resolveIncludePath swaps
std::filesystem::exists for a provider-aware ConfigFileExists so
{{include from ...}} directives find their targets inside the
bundle.
- config_manager::parseTemplateConfig: in bundled mode, skip the
std::filesystem::absolute() step -- the template path is a bundle
key like "sqls", not a filesystem path; turning it into
"/cwd/sqls" prevents the embedded provider from finding it.
- config_manager::loadEndpointConfigsRecursively: in bundled mode,
enumerate .yaml/.yml entries by prefix-scanning the bundle map
instead of std::filesystem::recursive_directory_iterator. The
EmbeddedArchiveFileProvider's ListFiles is non-recursive by
contract, so the walk is inlined here.
- config_manager::getFileProvider: in bundled mode, return a fresh
provider from FileProviderFactory so SQLTemplateProcessor reads
SQL templates from the bundle rather than the LocalFileProvider
baked into ConfigLoader.
Plus a small fix in sql_template_processor::getFullTemplatePath:
when the endpoint parser has already resolved templateSource against
its YAML's parent dir (which in bundled mode produces a full bundle
key like "sqls/hello.sql"), don't re-prepend the basePath. Mirrors
the existing absolute-path short-circuit just above.
test_self_packaging_http.py adds the three pytest cases from the
issue acceptance:
- #1 unbundled flapi serves /hello with 200 + body
- #3 bundled flapi from clean cwd (with the source tree deleted)
serves the same /hello
- #9 a SQL template using read_csv('embed://data/cities.csv')
returns the bundled CSV rows over HTTP
All 17 integration tests pass (existing CLI-level self-packaging
suite + env-override suite + the 3 new HTTP cases). 637/637 C++ unit
tests pass.
Closes #62.
jrosskopf
added a commit
that referenced
this pull request
Sep 15, 2026
P0 issue 1. flAPI had three separate clocks timing overlapping operations (api_server.cpp:218, mcp_tool_handler.cpp:14 and :35) and a request id that nothing outside the audit logger could see, so an audit line, a log line and a telemetry event could not be joined. RequestContext is the one object per request that fixes that; the HTTP span will hang off the same object later. It is created on EVERY request on EVERY route whether or not tracing is on, so allocation was a design constraint rather than an afterthought: fixed-width std::array for the ids (a 32-char W3C trace id exceeds libstdc++'s 15-byte SSO buffer, so std::string would allocate per request - measured in test_alloc_budget.cpp), const char* into static storage for the closed enumerations, string_view for raw_path and route_template, and an audit_params vector only populated when audit is enabled. Measured cost on the cheap routes: +6.6% TTFB median, well inside the 15% gate. Also closes drift bug #1: docs/CONFIG_REFERENCE.md:513 and examples/flapi.yaml have always claimed the audit log "covers both REST and MCP traffic", but the only AuditLogger call site was in the MCP tool handler. REST is now covered. Three behaviours worth calling out, each pinned by a test: - A 401 rejected in AuthMiddleware is audited. Crow does NOT call after_handle when a middleware completes the response inside before_handle (crow/http_connection.h:183-207), which is exactly what AuthMiddleware does, so a middleware that trusts after_handle silently loses every 401. Those paths now complete the request explicitly and after_handle is idempotent. - One audit line per operation. An MCP tools/call arrives as an HTTP POST, so the new middleware would report the same work twice under two names. MCP suppresses the transport-level line and keeps its richer tool-level one, carrying the shared request id across. Suppression is set at the MCP transport so adding REST coverage does not silently expand MCP's audit scope to handshakes. - Health probes are not audited. In Kubernetes they are the highest-volume route and carry no compliance information; auditing them would bury real entries. X-Request-Id is on every response and is always server-minted - an inbound value is never echoed, or a client could forge collisions and inject into log lines. Trace ids are emitted into the audit line only when non-empty, so the audit schema is byte-identical for operators who never enable tracing. The middleware deliberately does NOT resolve routes: AuthMiddleware and handleDynamicRequest already do, and a third O(N) scan would tax /health, which resolves nothing today. The handler writes the template back instead. Unit 705 passed, integration 580 passed, load gate passed.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
The document describes the issues encountered while setting up the docker-compose-bigquery environment.
Issue 1: bigquery extension fails to load sometimes
The error message in the logs is:
Issue 2: With no erros or warnings, the container fails with error code 139.
The error message in the logs is:
Issue 3: Swagger UI does not show api specs