Menu ▾ ▴

#207 D365 cannot be switched off: eleven bronze models ref stg_d365_fo__* directly, blocking a connector-less (multi-tenant) deployment

closed
nobody
None
2026-09-15
2026-09-15
Anonymous
No

Originally created by: grynn-in

What happened

erp_sources is documented as the single switch for which ERP staging models build, but it cannot actually be emptied:

# dbt_project.yml
# NOTE: d365_fo must stay in this list. The bronze layer refs several
# stg_d365_fo__* models directly (not via the canonical erp_sources loop), so
# removing d365_fo would disable models that bronze still depends on. The
# switch is "D365 mandatory, ERPNext optional", not a symmetric toggle.
erp_sources:

  - d365_fo

Eleven bronze models ref() a stg_d365_fo__* model directly rather than through the canonical loop:

bronze_budget_register_entries      stg_d365_fo__budget_register_entries
bronze_budget_transaction_lines     stg_d365_fo__budget_entries
bronze_consolidation_account_groups stg_d365_fo__consolidation_groups
bronze_exchange_rate_types          stg_d365_fo__exchange_rate_types
bronze_financial_dimension_values   stg_d365_fo__financial_dimension_values
bronze_financial_dimensions         stg_d365_fo__financial_dimensions
bronze_fiscal_calendar_years        stg_d365_fo__fiscal_calendar_years
bronze_fiscal_calendars             stg_d365_fo__fiscal_calendars
bronze_general_journal_account_entries  stg_d365_fo__gl_entries
bronze_general_journal_entries      stg_d365_fo__gl_journal_entries
bronze_main_account_categories      stg_d365_fo__main_account_categories

A customer with no D365 — the trial-balance-upload path, which is the canonical source since the decision of 13 Sep 2026 — still builds the entire D365 staging tree against empty or absent sources.

Why this now matters more

The multi-tenant direction (user decision, 15 Sep 2026) is to move the dbt project into the Frappe app — it is the right home for it — and to leave the ELT/ETL layer out. A multi-tenant deployment therefore has no D365 connector at all, and "D365 mandatory" stops being an inefficiency and becomes a hard blocker: the transformation layer would ship inside the app carrying a staging tree for a source no tenant has.

It also changes who owns the fix. Once dbt is app code, every tenant gets the same models, so "which sources exist" can no longer be a per-deployment edit to erp_sources — it has to resolve from site data, or the D365 branch has to be absent entirely.

Root cause

Bronze was written when D365 was the only source. erp_sources was added later as the canonical loop, and the pre-existing direct refs were never migrated onto it, so the switch is asymmetric by accident rather than by design.

Suggested fix

Sever the direct refs so erp_sources becomes the real switch:

  1. For each of the eleven, route through the canonical union the loop already builds, so an empty or D365-less erp_sources yields an empty relation rather than a missing ref.
  2. Make the trial-balance path a first-class member of that union rather than a fallback (konsol#200 makes the same point about the build preflight, which still gates on connector status).
  3. Prove it with a build whose erp_sources omits d365_fo, which should be a CI target once it passes.

Worth sequencing against the multi-tenant work rather than after it: the per-site ClickHouse change will touch the same model tree.

Repro

dbt build --vars '{erp_sources: []}' — models disabled, bronze still refs the disabled staging models.

🤖 Generated with Claude Code

https://claude.ai/code/session_01P3Pf9835FeLeXjRrYTTZ1M

Related

Tickets: #211

Discussion

  • Anonymous

    Anonymous - 2026-09-15

    Originally posted by: grynn-in

    The decision in konsolidat#90 changes the fix here

    Airbyte is off the roadmap (recorded 15 Sep 2026, konsolidat#90 closed as not planned). The ELT/ETL layer leaves scope entirely.

    So the suggested fix in this issue — route the eleven direct stg_d365_fo__* refs through the canonical erp_sources loop so the switch becomes symmetric — is now the wrong shape. There is no longer a D365 side to switch to. The work is to remove bronze's dependency on D365 staging, not to make it optional:

    • the eleven bronze models either take their input from the trial-balance path or cease to exist
    • erp_sources itself may not need to survive the change

    This should be sequenced inside the dbt-into-the-app move rather than before it, since that work touches the same tree and will have to answer the same question.

    🤖 Claude Code · https://claude.ai/code/session_01P3Pf9835FeLeXjRrYTTZ1M

     
  • Anonymous

    Anonymous - 2026-09-15

    Originally posted by: grynn-in

    Fixed by PR [#211].

     

    Related

    Tickets: #211

  • Anonymous

    Anonymous - 2026-09-15

    Ticket changed by: grynn-in

    • status: open --> closed
     

Log in to post a comment.