Skip to content

Conversation

@wing328
Copy link
Member

@wing328 wing328 commented Dec 29, 2025

Summary by cubic

Add environment variable placeholder support in openapitools.json so configs can reference ${VAR} or ${env.VAR} for dynamic values. Updated docs and tests to cover usage.

  • New Features
    • Replaces placeholders in strings, arrays, and nested objects.
    • Logs an error and leaves the token unchanged when the env var is missing.
    • README: documents env. and placeholders for repository queryUrl/downloadUrl.
    • Adds unit tests for replacement behavior and edge cases.

Written for commit 5325b17. Summary will update automatically on new commits.

based on #1031

@wing328 wing328 marked this pull request as ready for review December 29, 2025 17:52
Copy link
Contributor

@cubic-dev-ai cubic-dev-ai bot left a comment

Choose a reason for hiding this comment

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

1 issue found across 3 files

Prompt for AI agents (all issues)

Check if these issues are valid — if so, understand the root cause of each and fix them.


<file name="apps/generator-cli/src/app/services/config.service.ts">

<violation number="1" location="apps/generator-cli/src/app/services/config.service.ts:145">
P1: Calling `replacePlaceholders()` in `read()` will corrupt the config file when `set()` is used. The `set()` method calls `read()` to get the current config, modifies it, and writes it back. Since placeholders are now replaced during `read()`, the original `${VAR}` syntax will be permanently overwritten with resolved values. Consider applying placeholder replacement only in `get()` when returning values, not in `read()` which is also used for config modification.</violation>
</file>

Reply to cubic to teach it or ask questions. Tag @cubic-dev-ai to re-run a review.

fs.readJSONSync(this.configFile, { throws: false, encoding: 'utf8' }),
);

return this.replacePlaceholders(config);
Copy link
Contributor

@cubic-dev-ai cubic-dev-ai bot Dec 29, 2025

Choose a reason for hiding this comment

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

P1: Calling replacePlaceholders() in read() will corrupt the config file when set() is used. The set() method calls read() to get the current config, modifies it, and writes it back. Since placeholders are now replaced during read(), the original ${VAR} syntax will be permanently overwritten with resolved values. Consider applying placeholder replacement only in get() when returning values, not in read() which is also used for config modification.

Prompt for AI agents
Check if this issue is valid — if so, understand the root cause and fix it. At apps/generator-cli/src/app/services/config.service.ts, line 145:

<comment>Calling `replacePlaceholders()` in `read()` will corrupt the config file when `set()` is used. The `set()` method calls `read()` to get the current config, modifies it, and writes it back. Since placeholders are now replaced during `read()`, the original `${VAR}` syntax will be permanently overwritten with resolved values. Consider applying placeholder replacement only in `get()` when returning values, not in `read()` which is also used for config modification.</comment>

<file context>
@@ -137,10 +137,57 @@ export class ConfigService {
       fs.readJSONSync(this.configFile, { throws: false, encoding: &#39;utf8&#39; }),
     );
+
+    return this.replacePlaceholders(config);
+  }
+
</file context>
Fix with Cubic

@wing328 wing328 changed the title Jase88 feat/env variables feat(config): add support for environment variable placeholders in config Dec 29, 2025
@wing328 wing328 closed this Dec 30, 2025
@wing328 wing328 deleted the jase88-feat/env-variables branch December 30, 2025 16:41
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.

3 participants