Skip to content

test: configure via .cdsrc.json profiles instead of process.env.cds_* (#486) - #493

Merged
sjvans merged 2 commits into
developfrom
test/486-config-via-profiles
Aug 20, 2026
Merged

test: configure via .cdsrc.json profiles instead of process.env.cds_* (#486)#493
sjvans merged 2 commits into
developfrom
test/486-config-via-profiles

Conversation

@sjvans

@sjvans sjvans commented Aug 20, 2026

Copy link
Copy Markdown
Contributor

What

Replaces the load-order-fragile process.env.cds_requires_* / process.env.cds_* string-JSON test config with proper cds config: .cdsrc.json profiles (composed with --profile) and cds.test() args. Test-only + test-app-config change; no lib/ change.

Why

Setting config via process.env.cds_* string-JSON at module top is load-order-sensitive: it must run before any @sap/cds require or it is silently ignored (the root of the removed delete cds.env hack). cds already supports the same config declaratively via .cdsrc.json profiles.

Root cause of the old // REVISIT: ... package.json wins comments (why some config had to be done via env): cds loads config sources sequentially, package.json after .cdsrc.json, last-writer-wins. So a .cdsrc.json profile could never override a key that package.json set at its base. Fix: move those base defaults (log.cls_custom_fields, messaging.kind/file) from test/bookshop/package.json into test/bookshop/.cdsrc.json base, so the .cdsrc.json profiles (same source) win as intended.

Sites moved to profiles (all 8 — zero process.env.cds_* remain)

Site Was Now
logging.test.js (cls_custom_fields, tracing.exporter:false) cds_log, cds_requires_telemetry_tracing [logging] profile (+ base moved out of package.json)
tracing.test.js (sampler ignoreIncomingPaths) cds_requires_telemetry_tracing_sampler new [sampler-ignore-authors] profile, --profile 'tracing-in-memory, sampler-ignore-authors'
tracing-remote-native.test.js, tracing-attributes.test.js (native_fetch) cds_remote_native__fetch new [native-fetch] profile (remote.native_fetch: true), --profile 'tracing-in-memory, native-fetch'
passport.test.js (scheduling off) cds_requires_scheduling new [no-scheduling] profile, cds.test(dir, '--profile', 'no-scheduling')
tracing-messaging-{inboxed,persistent-outbox,without-outbox}.test.js (messaging kind/file/flags) cds_requires_messaging existing [inboxed]/[persistent-outbox]/[without-outbox] profiles now fully carry it (messaging base moved out of package.json)

.cdsrc.json changes

  • Added base requires.messaging (local-messaging / msg-box) and log.cls_custom_fields (moved from package.json).
  • [logging]: added requires.telemetry.tracing.exporter: false.
  • New profiles: [sampler-ignore-authors], [native-fetch], [no-scheduling].

Verification

  • Full sqlite suite: 65 passed / 12 skipped (identical to baseline, same skip set).
  • Each converted file passes individually on sqlite.
  • grep -rn "process.env.cds_" test/ → none remain.
  • eslint (test/) + oxfmt clean; grep -c int.repositories.cloud.sap package-lock.json = 0.

HANA CI caveat

Profile changes are DB-agnostic, but these run on HANA and could only be validated for config equivalence locally (config resolves identically to the old env), not executed: logging (runs on both), and the HANA-only tracing-messaging-inboxed + tracing-messaging-persistent-outbox. HANA CI must validate them.

No lib change. No behavior change.

Closes #486

@hyperspace-pr-bot

Copy link
Copy Markdown
Contributor

Summary

The following content is AI-generated and provides a summary of the pull request:


Replace process.env.cds_* Test Config with .cdsrc.json Profiles

Refactor

♻️ Replaces all load-order-fragile process.env.cds_requires_* / process.env.cds_* string-JSON test configuration with proper CDS declarative config via .cdsrc.json profiles and cds.test() --profile arguments. This is a test-only change with no modifications to lib/.

Changes

The root cause of the old fragility: process.env.cds_* assignments had to run before any @sap/cds require, or they were silently ignored. Additionally, package.json config loads after .cdsrc.json, meaning .cdsrc.json profiles could never override keys set in package.json's base. The fix moves those base defaults into .cdsrc.json so profiles in the same file correctly win.

  • test/bookshop/.cdsrc.json: Moved requires.messaging (local-messaging / msg-box) and log.cls_custom_fields base defaults here (from package.json). Added tracing.exporter: false to the [logging] profile. Added three new profiles: [sampler-ignore-authors], [native-fetch], and [no-scheduling].
  • test/bookshop/package.json: Removed messaging kind/file and log.cls_custom_fields from the CDS config base (moved to .cdsrc.json).
  • test/logging.test.js: Removed process.env.cds_log and process.env.cds_requires_telemetry_tracing assignments; config now lives in the [logging] profile.
  • test/passport.test.js: Removed process.env.cds_requires_scheduling = 'false'; replaced with cds.test(..., '--profile', 'no-scheduling').
  • test/tracing.test.js: Removed process.env.cds_requires_telemetry_tracing_sampler; now uses --profile 'tracing-in-memory, sampler-ignore-authors'.
  • test/tracing-remote-native.test.js & test/tracing-attributes.test.js: Removed process.env.cds_remote_native__fetch = 'true'; now uses --profile 'tracing-in-memory, native-fetch'.
  • test/tracing-messaging-inboxed.test.js, test/tracing-messaging-persistent-outbox.test.js, test/tracing-messaging-without-outbox.test.js: Removed process.env.cds_requires_messaging JSON overrides; messaging config now fully carried by the respective existing profiles ([inboxed], [persistent-outbox], [without-outbox]).

Jira Issues

  • #486: Tests configure CDS via process.env.cds_requires_* string-JSON instead of profiles/config

  • 🔄 Regenerate and Update Summary
  • ✏️ Insert as PR Description (deletes this comment)
  • 🗑️ Delete comment
PR Bot Information

Version: 1.29.33

@hyperspace-pr-bot hyperspace-pr-bot Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The PR is a clean refactoring that correctly replaces load-order-fragile process.env.cds_* overrides with declarative .cdsrc.json profiles. The only issue found is a minor inaccuracy in the logging.test.js comment that conflates the moved base value (["tenant_id"]) with the profile-level override (["foo"]), which could mislead future readers. One comment was posted to clarify this.

PR Bot Information

Version: 1.29.33

  • Correlation ID: e85349f0-9ccc-11f1-8c5f-fd242520031d
  • LLM: anthropic--claude-4.6-sonnet
  • File Content Strategy: Full file content
  • Event Trigger: pull_request.opened

Comment thread test/logging.test.js Outdated
Comment on lines +4 to +6
// - log.cls_custom_fields: ['foo'] (the base default from package.json's cds.log moved to
// .cdsrc.json so this profile can win — see #486; package.json config loads after .cdsrc.json
// and would otherwise override the profile)

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Inaccuracy: The comment says log.cls_custom_fields: ['foo'] is "the base default from package.json's cds.log moved to .cdsrc.json". What actually moved from package.json to the .cdsrc.json base is ["tenant_id"]; ["foo"] is the [logging] profile override — it was never in package.json. The comment conflates the two and will mislead future readers about what the base value is and why the profile wins.

Suggested change
// - log.cls_custom_fields: ['foo'] (the base default from package.json's cds.log moved to
// .cdsrc.json so this profile can win — see #486; package.json config loads after .cdsrc.json
// and would otherwise override the profile)
// - log.cls_custom_fields: ['foo'] (profile override; the base default ['tenant_id'] was moved
// from package.json into the .cdsrc.json base so this profile can win — see #486;
// package.json config loads after .cdsrc.json and would otherwise override the profile)

Double-check suggestion before committing. Edit this comment for amendments.


Please provide feedback on the review comment by checking the appropriate box:

  • 🌟 Awesome comment, a human might have missed that.
  • ✅ Helpful comment
  • 🤷 Neutral
  • ❌ This comment is not helpful

@sjvans
sjvans merged commit f125e34 into develop Aug 20, 2026
12 checks passed
@sjvans
sjvans deleted the test/486-config-via-profiles branch August 20, 2026 19:50
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.

1 participant