Skip to content

[codex] Fix bootstrap loading and HTTPS proxy handling#44

Merged
hcvdwerf merged 5 commits intomainfrom
codex/fix-metadata-sort-crash
Apr 21, 2026
Merged

[codex] Fix bootstrap loading and HTTPS proxy handling#44
hcvdwerf merged 5 commits intomainfrom
codex/fix-metadata-sort-crash

Conversation

@hcvdwerf
Copy link
Copy Markdown

@hcvdwerf hcvdwerf commented Apr 20, 2026

What changed

This PR fixes the local client bootstrap path and the Docker proxy setup used to reach an FDP backend.

It includes:

  • defensive bootstrap and entity-config handling so the UI shows a friendly fallback state instead of crashing when entity definitions are unavailable
  • normalization of backend resourceDefinitions into usable entity configs in the store
  • better diagnostics around bootstrap/API request failures
  • HTTPS-aware nginx proxy configuration for Docker, including correct upstream host forwarding and SNI support
  • README updates for running the client against an external HTTPS FDP backend

Why

Local runs were failing with:

Unable to load entity configuration.

The underlying issues were:

  • the frontend could end up with missing/unnormalized entity config data after bootstrap loading
  • the Docker nginx config was hardcoded to http:// and forwarded the wrong Host header, so proxying to an external HTTPS FDP backend failed

Impact

  • local Docker runs can now proxy correctly to https://fdp-test.healthdata.nl
  • users get a readable warning state when entity definitions are unavailable instead of a broken page
  • bootstrap/API failures are easier to diagnose from console output

Validation

Validated with:

  • npm run build
  • fresh Docker image build from the current branch
  • container run with:
    • FDP_HOST=fdp-test.healthdata.nl
    • FDP_SCHEME=https
    • API_URL=/
  • verification from inside the running container that:
    • /config.js exposes apiURL: '/'
    • /configs/bootstrap returns FDP bootstrap JSON with resourceDefinitions
    • / serves the SPA index page for HTML requests

Summary by Sourcery

Improve robustness of entity bootstrap handling and Docker HTTPS proxying for the FDP client.

New Features:

  • Display a user-friendly warning page when entity configuration cannot be loaded instead of rendering a broken entity view.

Bug Fixes:

  • Normalize and construct entity and repository configurations from backend resource definitions so entity lookups by name and UUID work reliably.
  • Prevent crashes caused by missing labels, paths, or specs by defensively normalizing values before sorting and grouping entities and metadata.
  • Ensure child entity lists fail gracefully when the child entity configuration is unavailable.
  • Avoid attempting to fetch entity data when the entity configuration or its API details are missing.

Enhancements:

  • Add detailed logging and error reporting for bootstrap loading, API request failures, and missing entity configurations to aid diagnostics.
  • Refine error message extraction logic to present clearer messages from API responses or underlying errors.
  • Improve SHACL parser and metadata sorting implementations for clarity and reuse while preserving behavior.
  • Tighten TypeScript typing around entity configurations and specs in entity creation flows.

Build:

  • Log loaded configuration values at startup to aid local and container debugging of client and API URLs.

Deployment:

  • Update nginx configuration and startup script to support configurable HTTP/HTTPS upstream schemes, correct host forwarding, and SNI when proxying to external FDP backends.
  • Document and exemplify Docker run options for targeting external HTTPS FDP instances via the container nginx proxy.

Documentation:

  • Extend README with concrete examples and guidance for running the client against external HTTPS FDP backends behind the nginx proxy.

@sourcery-ai
Copy link
Copy Markdown

sourcery-ai Bot commented Apr 20, 2026

Reviewer's Guide

Improve robustness of FDP client bootstrap/entity loading and Docker HTTPS proxying, adding better error handling, normalization of entity configs, and diagnostics while updating nginx and documentation for HTTPS backends.

Sequence diagram for FDP client bootstrap and entity config normalization

sequenceDiagram
  actor User
  participant Browser
  participant VueApp_main_ts as VueApp_main_ts
  participant ApiConfigs as ApiConfigs
  participant FDPBackend as FDPBackend
  participant EntitiesStore as EntitiesStore

  User->>Browser: Load SPA
  Browser->>VueApp_main_ts: Execute main_ts
  VueApp_main_ts->>ApiConfigs: configs.getBootstrap()
  ApiConfigs->>FDPBackend: GET /configs/bootstrap
  FDPBackend-->>ApiConfigs: 200 JSON with resourceDefinitions
  ApiConfigs-->>VueApp_main_ts: response
  VueApp_main_ts->>VueApp_main_ts: Read response.data
  VueApp_main_ts->>Browser: Set globalThis.config from bootstrap
  VueApp_main_ts->>VueApp_main_ts: entitySpecs = resourceDefinitions
  VueApp_main_ts->>EntitiesStore: createEntitiesModule(createEntityConfigs(entitySpecs))
  EntitiesStore->>EntitiesStore: normalizeConfig for each entity

  alt Bootstrap request fails
    FDPBackend-->>ApiConfigs: Network error or non 2xx
    ApiConfigs-->>VueApp_main_ts: error
    VueApp_main_ts->>VueApp_main_ts: Log detailed error
    VueApp_main_ts->>EntitiesStore: createEntitiesModule(createEntityConfigs([]))
    note over EntitiesStore: Store initialized with empty entityConfigs
  end
Loading

Sequence diagram for entity lookup and UI fallback on missing config

sequenceDiagram
  actor User
  participant Router as VueRouter
  participant Store as EntitiesStore
  participant EntityViewPage as EntityViewPage
  participant EntityView as EntityView

  User->>Router: Navigate to /entity/:entity
  Router->>EntityViewPage: Mount component
  EntityViewPage->>Store: getters.entities/config(entity)
  Store->>Store: getConfigFor(entity)
  Store->>Store: normalizeConfig(state, config)
  alt Config found and normalized
    Store-->>EntityViewPage: EntityConfig
    EntityViewPage->>EntityViewPage: this.config = EntityConfig
    EntityViewPage->>EntityView: Render with config
  else Config missing or invalid
    Store-->>EntityViewPage: undefined
    EntityViewPage->>EntityViewPage: Log missing config and available keys
    EntityViewPage-->>User: Show warning alert "Unable to load entity configuration."
  end
Loading

Class diagram for entity configuration normalization in store

classDiagram
  class EntitySpec {
    +string uuid
    +string urlPrefix
    +string name
  }

  class EntityConfig {
    +EntitySpec entitySpec
    +string uuid
    +any api
    +any parentEntity
    +any children
    +list createChildrenList(entitySpec, childSpec, graph, meta)
  }

  class RepositoryConfig {
    +EntitySpec entitySpec
    +string uuid
    +any api
    +any parentEntity
    +any children
    +list createChildrenList(entitySpec, childSpec, graph, meta)
  }

  class EntityState {
    +Record~string, any~ entityConfigs
  }

  class StoreHelpers {
    +getEntitySpec(config) EntitySpec
    +getSpecsByUuid(state) Record~string, EntitySpec~
    +normalizeConfig(state, config) EntityConfig
    +getConfigFor(state, entity) EntityConfig
  }

  EntitySpec <.. EntityConfig : wraps
  EntitySpec <.. RepositoryConfig : wraps

  EntityState o--> EntityConfig : raw configs stored
  EntityState o--> RepositoryConfig : raw configs stored

  StoreHelpers ..> EntityState : uses
  StoreHelpers ..> EntityConfig : returns
  StoreHelpers ..> RepositoryConfig : returns
  StoreHelpers ..> EntitySpec : uses

  class EntitiesGetters {
    +config(entity) EntityConfig
    +configByUuid(uuid) EntityConfig
  }

  EntitiesGetters ..> StoreHelpers : calls normalizeConfig
Loading

File-Level Changes

Change Details Files
Normalize and harden SHACL parsing, entity configuration handling, and child entity list rendering to cope with missing or malformed data.
  • Ensure group and field comparison routines safely normalize labels before locale-based comparison.
  • Introduce a mergeAllShapes helper in SHACLParser to centralize shape reduction and use it across parse variants for clearer control flow.
  • Normalize entity configs coming from bootstrap resourceDefinitions into EntityConfig/RepositoryConfig instances, with lookup helpers by ID and UUID.
  • Guard EntityCreate, EntityView, EntityEdit, and EntitySettings pages and EntityBase against missing configs, showing errors or fallbacks instead of crashing.
  • Add defensive checks and explicit Status errors when child entity configurations cannot be resolved in ItemList.
src/components/ShaclForm/Parser/SHACLParser.ts
src/store/modules/entities.ts
src/views/EntityCreatePage/index.vue
src/views/EntityViewPage/index.vue
src/views/EntityEditPage/index.vue
src/views/EntitySettingsPage/index.vue
src/components/ItemList/index.vue
src/components/EntityBase/index.ts
src/components/EntityView/index.vue
Improve bootstrap loading flow and runtime diagnostics for configuration and API failures.
  • Adjust bootstrap call to work with axios-style responses, populating global config from response.data and extracting resourceDefinitions into entitySpecs.
  • Add structured console logging for successful bootstrap load, including number of entity specs.
  • On bootstrap failure, log detailed error info (status, URL, response body) and continue with empty specs to allow UI fallback states.
  • Log startup and configuration details (publicPath, clientURL, apiURL, window config) during application boot.
src/main.ts
src/config.ts
Enhance API error observability and user-facing status messages.
  • Add a global axios response interceptor that logs failed API requests with method, URL, status, and response data.
  • Extend Status.setErrorFromResponse to select the best available error message (response.data.message, response body string, or error.message) and to always populate errorCode from HTTP status.
src/api/request.ts
src/utils/Status.ts
Fix Docker/nginx proxy behavior for HTTPS backends and document correct usage.
  • Update nginx default.conf to forward the upstream host correctly, set X-Forwarded-Host, and enable SNI via proxy_ssl_server_name on.
  • Allow proxy_pass to respect a configurable FDP_SCHEME (http/https) and wire it into the nginx config.
  • Extend nginx startup script to normalize FDP_HOST, validate/normalize FDP_SCHEME, and substitute both into the generated nginx configuration.
  • Update README with a concrete example for running against an external HTTPS FDP backend with API_URL=/ and clarify guidance for HTTPS-only backends.
nginx/default.conf
nginx/start.sh
README.md

Tips and commands

Interacting with Sourcery

  • Trigger a new review: Comment @sourcery-ai review on the pull request.
  • Continue discussions: Reply directly to Sourcery's review comments.
  • Generate a GitHub issue from a review comment: Ask Sourcery to create an
    issue from a review comment by replying to it. You can also reply to a
    review comment with @sourcery-ai issue to create an issue from it.
  • Generate a pull request title: Write @sourcery-ai anywhere in the pull
    request title to generate a title at any time. You can also comment
    @sourcery-ai title on the pull request to (re-)generate the title at any time.
  • Generate a pull request summary: Write @sourcery-ai summary anywhere in
    the pull request body to generate a PR summary at any time exactly where you
    want it. You can also comment @sourcery-ai summary on the pull request to
    (re-)generate the summary at any time.
  • Generate reviewer's guide: Comment @sourcery-ai guide on the pull
    request to (re-)generate the reviewer's guide at any time.
  • Resolve all Sourcery comments: Comment @sourcery-ai resolve on the
    pull request to resolve all Sourcery comments. Useful if you've already
    addressed all the comments and don't want to see them anymore.
  • Dismiss all Sourcery reviews: Comment @sourcery-ai dismiss on the pull
    request to dismiss all existing Sourcery reviews. Especially useful if you
    want to start fresh with a new review - don't forget to comment
    @sourcery-ai review to trigger a new review!

Customizing Your Experience

Access your dashboard to:

  • Enable or disable review features such as the Sourcery-generated pull request
    summary, the reviewer's guide, and others.
  • Change the review language.
  • Add, remove or edit custom review instructions.
  • Adjust other review settings.

Getting Help

@hcvdwerf hcvdwerf marked this pull request as ready for review April 20, 2026 20:08
Comment thread src/utils/Status.ts Outdated
Comment thread src/views/EntityViewPage/index.vue Outdated
Comment thread src/components/EntityBase/index.ts
Comment thread src/store/modules/entities.ts Outdated
Comment thread src/store/modules/entities.ts Outdated
@hcvdwerf hcvdwerf merged commit 393dbe0 into main Apr 21, 2026
2 checks passed
@hcvdwerf hcvdwerf deleted the codex/fix-metadata-sort-crash branch April 21, 2026 09:19
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants