Skip to content

POC sample apps for new iparam structure - #11

Closed
cb-gaganbankey wants to merge 2 commits into
mainfrom
sample-apps-for-new-iparams-structure
Closed

POC sample apps for new iparam structure#11
cb-gaganbankey wants to merge 2 commits into
mainfrom
sample-apps-for-new-iparams-structure

Conversation

@cb-gaganbankey

@cb-gaganbankey cb-gaganbankey commented Jun 3, 2026

Copy link
Copy Markdown
Contributor

CHANGELOG

REPLACE_ME_WITH_CHANGELOG

SUMMARY

REPLACE_ME_WITH_SUMMARY_OF_THE_CHANGES

FUNCTIONAL AUTOMATION CHANGES PR

  • Yes
    • If Yes, PR :
  • No
    • If No, Reason:

AUTOMATION TEST REPORT URL

REPLACE_ME_WITH_TEST_REPORT_URL

AREAS OF IMPACT

REPLACE_ME_WITH_AREAS_OF_IMPACT_OR_NA

TYPE OF CHANGE

  • 🐞 Bugfix
  • 🌟 Feature
  • ✨ Enhancement
  • 🧪 Unit Test Cases
  • 📔 Documentation
  • ⚙️ Chore - Build Related / Configuration / Others

DOCUMENTATION

REPLACE_ME_WITH_DOCUMENTATION_LINK_OR_NA

Adds two proof-of-concept sample applications demonstrating grouped iParam configurations: one accesses parameters directly, while the other scopes them by section. Each includes manifests, parameter definitions, handlers for invoice-generated events, local configuration, documentation, type declarations, and test fixtures.

@snyk-io

snyk-io Bot commented Jun 3, 2026

Copy link
Copy Markdown

Snyk checks have failed. 2 issues have been found so far.

Status Scan Engine Critical High Medium Low Total (2)
Open Source Security 0 0 0 0 0 issues
Licenses 0 0 0 0 0 issues
Code Security 0 0 0 0 0 issues
Secrets 0 2 0 0 2 issues

💻 Catch issues earlier using the plugins for VS Code, JetBrains IDEs, Visual Studio, and Eclipse.

@github-actions

github-actions Bot commented Jun 3, 2026

Copy link
Copy Markdown
Fails
🚫

ℹ️ Please fill the CHANGELOG section in the PR description.

🚫 📋 FUNCTIONAL AUTOMATION CHANGES PR is mandatory. Please check either "Yes" or "No".
🚫

ℹ️ Please replace REPLACE_ME_WITH_TEST_REPORT_URL with the actual automation test report URL in the PR description.

Messages
📖 👮 Hey cb-gaganbankey. Please address the failures to get this PR approved.

Generated by 🚫 dangerJS against 268a1ef

@hivel-marco hivel-marco Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

PR Complexity Score: 4.8 - Moderate

View Breakdown
  • Lines Changed: 727
  • Files Changed: 18
  • Complexity Added: 16
  • Raw Score: 92.54
⚠️ Sensitive Data (PII/ Secrets) Detected
FileTypesCount
sample-apps/iparams-new-structure-with-groups/poc-sample-app-iparam-access-with-section/test_data/invoice_generated.json
LineTypePreview
PII: Email Addressmanideep@chargebee.c...
Email Address1
sample-apps/iparams-new-structure-with-groups/poc-sample-app-with-direct-iparam-access/test_data/invoice_generated.json
LineTypePreview
PII: Email Addressmanideep@chargebee.c...
Email Address1
sample-apps/iparams-new-structure-with-groups/poc-sample-app-with-direct-iparam-access/types/types.d.ts
LineTypePreview
40Secret: Secret Keyword[Secret Keyword]
Secret Keyword1
Overview

This PR adds two proof-of-concept sample apps demonstrating different strategies for accessing installation parameters (iparams) when using sectioned iparam definitions.
One sample accesses iparams via section-scoped keys, allowing duplicate parameter names across sections, while the other flattens iparams into top-level keys, requiring globally unique parameter names.
Both apps showcase handling invoice_generated events, applying processing and late payment fees based on configured iparams, and include type definitions, local config, and test data.

Key Changes
  • Introduces poc-sample-app-iparam-access-with-section, where iparams are accessed as nested values under section names (e.g., payload.iparams.processing_fee_configuration.fee_percentage), explicitly supporting duplicate parameter names across sections.
  • Introduces poc-sample-app-with-direct-iparam-access, where iparams are read as flat keys (e.g., payload.iparams.processing_fee_percentage), illustrating a model where parameter names must be unique across the app.
  • Adds handler logic in both apps to compute and apply processing fees (with a cap) and late payment fees for invoice_generated events, reading percentages and limits from iparams.
  • Provides type definitions (types.d.ts) for event payloads and iparam structures for each app, aligning with the differing iparam access patterns (sectioned vs flat).
  • Supplies local configuration files (iparams.local.json), JS config (jsconfig.json), manifests, environment variable templates (.env), and example invoice_generated event payloads for testing.
Risks & Considerations
  • Divergent iparam typing between the two apps (iparams as sectioned vs flat) may cause confusion if samples are reused or combined without care.
  • The handlers assume specific iparam shapes and presence; missing or malformed iparams could cause runtime NaN computations if not validated before use.
  • Test event data has invoices with status: "paid" and total: 0, so fee paths may not be exercised unless test data or logic is adjusted.
  • None of the handlers currently implement the body of applyAdditionalFee, so downstream integrators must ensure actual mutation/side effects are correctly implemented.
File-level change summary
File Change summary
sample-apps/iparams-new-structure-with-groups/poc-sample-app-iparam-access-with-section/.env Adds environment variable template for read-only/read-write API keys and site domain for the section-based iparam sample app.
sample-apps/iparams-new-structure-with-groups/poc-sample-app-iparam-access-with-section/README.md Documents the section-based iparam access pattern, including example handler usage, iparams.local.json, and guidance on duplicate parameter names.
sample-apps/iparams-new-structure-with-groups/poc-sample-app-iparam-access-with-section/handler/handler.js Implements the invoiceGeneratedHandler that reads fee configuration from section-scoped iparams and computes/apply additional invoice fees.
sample-apps/iparams-new-structure-with-groups/poc-sample-app-iparam-access-with-section/iparams.json Defines installation parameters grouped into processing_fee_configuration and late_payment_fee_configuration sections with shared parameter names like fee_percentage.
sample-apps/iparams-new-structure-with-groups/poc-sample-app-iparam-access-with-section/iparams.local.json Provides local values for processing and late payment fee configuration using section-scoped keys matching iparams.json.
sample-apps/iparams-new-structure-with-groups/poc-sample-app-iparam-access-with-section/jsconfig.json Configures JavaScript compiler options and path aliases for the section-based iparam sample app.
sample-apps/iparams-new-structure-with-groups/poc-sample-app-iparam-access-with-section/manifest.json Declares the invoice_generated event mapping to the invoiceGeneratedHandler for the section-based sample.
sample-apps/iparams-new-structure-with-groups/poc-sample-app-iparam-access-with-section/test_data/invoice_generated.json Adds a sample invoice_generated event payload for testing the section-based handler.
sample-apps/iparams-new-structure-with-groups/poc-sample-app-iparam-access-with-section/types/types.d.ts Introduces TypeScript definitions for event records, section-based iparam inputs, and handler payloads for the section-based app.
sample-apps/iparams-new-structure-with-groups/poc-sample-app-with-direct-iparam-access/.env Adds environment variable template for read-only/read-write API keys and site domain for the direct iparam access sample app.
sample-apps/iparams-new-structure-with-groups/poc-sample-app-with-direct-iparam-access/README.md Documents the direct (flat) iparam access pattern, including example handler usage, iparams.local.json, and note that duplicate names are not allowed.
sample-apps/iparams-new-structure-with-groups/poc-sample-app-with-direct-iparam-access/handler/handler.js Implements the invoiceGeneratedHandler that reads fee configuration from flat iparam keys and computes/apply additional invoice fees.
sample-apps/iparams-new-structure-with-groups/poc-sample-app-with-direct-iparam-access/iparams.json Defines installation parameters in sections but with globally unique parameter names that are read as flat iparam keys.
sample-apps/iparams-new-structure-with-groups/poc-sample-app-with-direct-iparam-access/iparams.local.json Provides local values for flat processing and late payment fee parameters matching the handler’s expected key names.
sample-apps/iparams-new-structure-with-groups/poc-sample-app-with-direct-iparam-access/jsconfig.json Configures JavaScript compiler options and path aliases for the direct iparam access sample app.
sample-apps/iparams-new-structure-with-groups/poc-sample-app-with-direct-iparam-access/manifest.json Declares the invoice_generated event mapping to the invoiceGeneratedHandler for the direct-access sample.
sample-apps/iparams-new-structure-with-groups/poc-sample-app-with-direct-iparam-access/test_data/invoice_generated.json Adds a sample invoice_generated event payload for testing the direct-access handler.
sample-apps/iparams-new-structure-with-groups/poc-sample-app-with-direct-iparam-access/types/types.d.ts Introduces TypeScript definitions for event records, flat iparam inputs, and handler payloads for the direct-access app.

Comment on lines +27 to +33
const processingFeePercentage = Number(payload.iparams.processing_fee_percentage);
const processingFeeLimit = Number(payload.iparams.processing_fee_limit);
const latePaymentFeePercentage = Number(payload.iparams.late_payment_fee_percentage);

const isUnpaid = invoice.status !== 'paid';
const hasChargeableTotal = invoice.total > 0;
const isPastDue = invoice.due_date < payload.event.occurred_at;

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Priority: 🟠 HIGH

Problem: Installation parameter values are coerced with Number(...) and used directly without any validation, so missing or non-numeric iparams will propagate NaN into fee calculations and eventually into applyAdditionalFee.

Why: If any of processing_fee_percentage, processing_fee_limit, or late_payment_fee_percentage is undefined or not a valid number, Number() returns NaN; this causes calculateAdditionalFee and Math.min to return NaN, leading to incorrect or invalid fee amounts being applied at runtime.

How to Fix: After converting the iparams to numbers, explicitly validate that they are finite numeric values and bail out early if they are not, preventing NaN values from entering the fee calculation logic.

Suggested change
const processingFeePercentage = Number(payload.iparams.processing_fee_percentage);
const processingFeeLimit = Number(payload.iparams.processing_fee_limit);
const latePaymentFeePercentage = Number(payload.iparams.late_payment_fee_percentage);
const isUnpaid = invoice.status !== 'paid';
const hasChargeableTotal = invoice.total > 0;
const isPastDue = invoice.due_date < payload.event.occurred_at;
const processingFeePercentage = Number(payload.iparams.processing_fee_percentage);
const processingFeeLimit = Number(payload.iparams.processing_fee_limit);
const latePaymentFeePercentage = Number(payload.iparams.late_payment_fee_percentage);
if (
!Number.isFinite(processingFeePercentage) ||
!Number.isFinite(processingFeeLimit) ||
!Number.isFinite(latePaymentFeePercentage)
) {
return;
}
const isUnpaid = invoice.status !== 'paid';
const hasChargeableTotal = invoice.total > 0;
const isPastDue = invoice.due_date < payload.event.occurred_at;

Comment on lines +97 to +99
"source": "admin_console",
"user": "manideep@chargebee.com",
"webhook_status": "scheduled",

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Priority: 🟠 HIGH

Problem: The user field contains what appears to be a real email address ("manideep@chargebee.com"), which introduces unnecessary personally identifiable information (PII) into the repository.

Why: Shipping real or potentially real user/staff email addresses in version control is a privacy and security risk and can lead to unsolicited contact or data exposure; sample payloads should use clearly fictitious, non-identifiable values instead.

How to Fix: Replace the real-looking email address with an obviously dummy/test email (e.g., using example.com) while preserving the payload structure.

Suggested change
"source": "admin_console",
"user": "manideep@chargebee.com",
"webhook_status": "scheduled",
"source": "admin_console",
"user": "user@example.com",
"webhook_status": "scheduled",

@coderabbitai

coderabbitai Bot commented Jul 21, 2026

Copy link
Copy Markdown

Review Change Stack

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Enterprise

Run ID: 2cec0f12-a5fc-42db-82c5-fa274ecc651c

📥 Commits

Reviewing files that changed from the base of the PR and between 862a50f and 268a1ef.

📒 Files selected for processing (18)
  • sample-apps/iparams-new-structure-with-groups/poc-sample-app-iparam-access-with-section/.env
  • sample-apps/iparams-new-structure-with-groups/poc-sample-app-iparam-access-with-section/README.md
  • sample-apps/iparams-new-structure-with-groups/poc-sample-app-iparam-access-with-section/handler/handler.js
  • sample-apps/iparams-new-structure-with-groups/poc-sample-app-iparam-access-with-section/iparams.json
  • sample-apps/iparams-new-structure-with-groups/poc-sample-app-iparam-access-with-section/iparams.local.json
  • sample-apps/iparams-new-structure-with-groups/poc-sample-app-iparam-access-with-section/jsconfig.json
  • sample-apps/iparams-new-structure-with-groups/poc-sample-app-iparam-access-with-section/manifest.json
  • sample-apps/iparams-new-structure-with-groups/poc-sample-app-iparam-access-with-section/test_data/invoice_generated.json
  • sample-apps/iparams-new-structure-with-groups/poc-sample-app-iparam-access-with-section/types/types.d.ts
  • sample-apps/iparams-new-structure-with-groups/poc-sample-app-with-direct-iparam-access/.env
  • sample-apps/iparams-new-structure-with-groups/poc-sample-app-with-direct-iparam-access/README.md
  • sample-apps/iparams-new-structure-with-groups/poc-sample-app-with-direct-iparam-access/handler/handler.js
  • sample-apps/iparams-new-structure-with-groups/poc-sample-app-with-direct-iparam-access/iparams.json
  • sample-apps/iparams-new-structure-with-groups/poc-sample-app-with-direct-iparam-access/iparams.local.json
  • sample-apps/iparams-new-structure-with-groups/poc-sample-app-with-direct-iparam-access/jsconfig.json
  • sample-apps/iparams-new-structure-with-groups/poc-sample-app-with-direct-iparam-access/manifest.json
  • sample-apps/iparams-new-structure-with-groups/poc-sample-app-with-direct-iparam-access/test_data/invoice_generated.json
  • sample-apps/iparams-new-structure-with-groups/poc-sample-app-with-direct-iparam-access/types/types.d.ts

Walkthrough

Adds two proof-of-concept sample apps for invoice fee processing: one reads iParams through section names, while the other reads flattened parameter keys. Both include schemas, handlers, manifests, local configurations, types, fixtures, tooling, and documentation.

Changes

Section-scoped iParam access

Layer / File(s) Summary
Section-scoped fee handler and app contract
sample-apps/.../poc-sample-app-iparam-access-with-section/{iparams.json,iparams.local.json,types/*,handler/*,manifest.json}
Defines grouped fee parameters, typed handler payloads, invoice event wiring, and conditional processing and late-payment fee calculations using section-qualified iParams.
Section-scoped sample support
sample-apps/.../poc-sample-app-iparam-access-with-section/{README.md,.env,jsconfig.json,test_data/*}
Documents section-scoped access and provides local configuration, JavaScript tooling, environment placeholders, and an invoice event fixture.

Direct iParam access

Layer / File(s) Summary
Direct-access fee handler and app contract
sample-apps/.../poc-sample-app-with-direct-iparam-access/{iparams.json,iparams.local.json,types/*,handler/*,manifest.json}
Defines grouped fee parameters, flat iParam typing, invoice event wiring, and conditional processing and late-payment fee calculations using direct parameter keys.
Direct-access sample support
sample-apps/.../poc-sample-app-with-direct-iparam-access/{README.md,.env,jsconfig.json,test_data/*}
Documents flat iParam access and provides local configuration, JavaScript tooling, environment placeholders, and an invoice event fixture.

Estimated code review effort: 3 (Moderate) | ~20 minutes

🚥 Pre-merge checks | ✅ 1
✅ Passed checks (1 passed)
Check name Status Explanation
Docstring Coverage ✅ Passed Docstring coverage is 100.00% which is sufficient. The required threshold is 80.00%.

Warning

There were issues while running some tools. Please review the errors and either fix the tool's configuration or disable the tool if it's a critical failure.

🔧 Checkov (3.3.8)
sample-apps/iparams-new-structure-with-groups/poc-sample-app-iparam-access-with-section/iparams.json

Traceback (most recent call last):
File "/usr/local/bin/checkov", line 2, in
from checkov.main import Checkov
ModuleNotFoundError: No module named 'checkov'

sample-apps/iparams-new-structure-with-groups/poc-sample-app-iparam-access-with-section/iparams.local.json

Traceback (most recent call last):
File "/usr/local/bin/checkov", line 2, in
from checkov.main import Checkov
ModuleNotFoundError: No module named 'checkov'

sample-apps/iparams-new-structure-with-groups/poc-sample-app-iparam-access-with-section/jsconfig.json

Traceback (most recent call last):
File "/usr/local/bin/checkov", line 2, in
from checkov.main import Checkov
ModuleNotFoundError: No module named 'checkov'

  • 7 others

Comment @coderabbitai help to get the list of available commands.

"webhook_status": "scheduled",
"webhooks": [
{
"id": "whv2_AzZX7CUVnj5rB1ZHq",

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Detected a generic secret, which could lead to unauthorized access and sensitive data exposure.

⚠️ 1 location in this file

CWE-798: Generic Secret Key | Learn more about this vulnerability

Details and remediation

Why this is dangerous

Attackers can discover hardcoded credentials in source code to gain unauthorized access, escalate privileges, steal data, or disrupt services. If you reuse credentials across systems or environments, the impact increases.

Immediate action

  • Treat hardcoded credentials as compromised.
  • Remove the credentials from the code.
  • Rotate or revoke the credential and update all affected systems.
  • Store the new secret in a secrets manager or vault, or inject the secret using environment variables at runtime.

Preventing future exposure

  • Do not hardcode secrets.
  • Use pre-commit hooks and automated secrets scanning to prevent accidental commits.
  • Use secrets management tools, such as vaulting, environment injection, or secure configuration.
  • Use least-privilege credentials and strong salted hashes for stored passwords.
  • Add secure authentication practices to the development workflow.

You can view, fix, and ignore this issue in the Snyk Web UI

"webhook_status": "scheduled",
"webhooks": [
{
"id": "whv2_AzZX7CUVnj5rB1ZHq",

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Detected a generic secret, which could lead to unauthorized access and sensitive data exposure.

⚠️ 1 location in this file

CWE-798: Generic Secret Key | Learn more about this vulnerability

Details and remediation

Why this is dangerous

Attackers can discover hardcoded credentials in source code to gain unauthorized access, escalate privileges, steal data, or disrupt services. If you reuse credentials across systems or environments, the impact increases.

Immediate action

  • Treat hardcoded credentials as compromised.
  • Remove the credentials from the code.
  • Rotate or revoke the credential and update all affected systems.
  • Store the new secret in a secrets manager or vault, or inject the secret using environment variables at runtime.

Preventing future exposure

  • Do not hardcode secrets.
  • Use pre-commit hooks and automated secrets scanning to prevent accidental commits.
  • Use secrets management tools, such as vaulting, environment injection, or secure configuration.
  • Use least-privilege credentials and strong salted hashes for stored passwords.
  • Add secure authentication practices to the development workflow.

You can view, fix, and ignore this issue in the Snyk Web UI

@github-actions

Copy link
Copy Markdown

⛔ PR has more than 250 additions. Split it into smaller PRs. It contains 304 extra lines.

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