Skip to content

Fix custom_properties diffing when config uses property_name#978

Merged
decyjphr merged 5 commits into
main-enterprisefrom
copilot/fix-typeerror-in-customproperties
May 12, 2026
Merged

Fix custom_properties diffing when config uses property_name#978
decyjphr merged 5 commits into
main-enterprisefrom
copilot/fix-typeerror-in-customproperties

Conversation

Copy link
Copy Markdown
Contributor

Copilot AI commented May 12, 2026

Bug Fix

What was the bug?

custom_properties entries in repo/suborg YAML were ignored when authored with property_name instead of name. As a result, safe-settings did not detect/add expected property values (for example, ent-ownership: expert-services).

How did you fix it?

  • Normalize config entries across both key shapes

    • Updated CustomProperties.normalizeEntries() to accept either name or property_name from config entries.
    • Kept normalization behavior consistent by lowercasing the resolved property key before diffing.
  • Harden entry handling

    • Added guards to skip invalid/non-object entries and entries without a valid string key.
  • Add regression coverage

    • Extended custom properties unit tests to cover config entries defined with property_name.

Testing

  • Added/updated unit coverage in test/unit/lib/plugins/custom_properties.test.js for property_name-based config input.
custom_properties:
  - property_name: ent-ownership
    value: expert-services

This now normalizes to the same internal shape as name, so the diff logic detects and applies the property update.

Copilot AI changed the title [WIP] Fix TypeError in CustomProperties normalize method Fix CustomProperties normalize() regression with paginated response shape differences May 12, 2026
Copilot AI requested a review from decyjphr May 12, 2026 00:08
Copilot AI changed the title Fix CustomProperties normalize() regression with paginated response shape differences Fix custom_properties diffing when config uses property_name May 12, 2026
@decyjphr decyjphr marked this pull request as ready for review May 12, 2026 03:52
Copilot AI review requested due to automatic review settings May 12, 2026 03:52
@decyjphr decyjphr merged commit 3d61f1f into main-enterprise May 12, 2026
6 checks passed
@decyjphr decyjphr deleted the copilot/fix-typeerror-in-customproperties branch May 12, 2026 03:53
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

Fixes a diffing bug in the custom_properties plugin where config entries authored with property_name (instead of name) were not normalized consistently, causing intended property updates to be missed.

Changes:

  • Updated config entry normalization to accept both name and property_name and lowercase the resolved key prior to diffing.
  • Hardened normalization of fetched custom properties to handle both property_name and name shapes and skip invalid entries.
  • Added Jest regression tests covering property_name in config and mixed response shapes during pagination normalization.
Show a summary per file
File Description
lib/plugins/custom_properties.js Extends normalization logic to accept both name and property_name, adds basic guards, and ensures lowercased keys are used for comparisons.
test/unit/lib/plugins/custom_properties.test.js Adds regression coverage for property_name-based config input and mixed key shapes in paginated results.

Copilot's findings

Tip

Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comments suppressed due to low confidence (1)

lib/plugins/custom_properties.js:68

  • Same issue as in normalizeEntries: property.property_name || property.name will ignore a valid name/property_name if the first field is present but non-string and truthy. Prefer checking typeof for each candidate and using the first string value to avoid silently dropping valid records.
      const propertyName = property.property_name || property.name

      if (typeof propertyName !== 'string') {
        return normalizedProperties
      }

      normalizedProperties.push({
        name: propertyName.toLowerCase(),
        value: property.value
  • Files reviewed: 2/2 changed files
  • Comments generated: 2

Comment on lines +20 to +28
const entryName = entry.name || entry.property_name

if (typeof entryName !== 'string') {
return normalizedEntries
}

normalizedEntries.push({
name: entryName.toLowerCase(),
value: entry.value
Comment on lines +66 to +71
it('should normalize paginated custom properties when property name shape differs', async () => {
const mockResponse = [
{ name: 'Owner', value: 'My Team' },
{ property_name: 'Criticality', value: 'High' },
{ value: 'ignored' }
]
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.

TypeError in CustomProperties normalize() after upgrading to 2.1.19

3 participants