Skip to content

Conversation

@louis-bompart
Copy link
Collaborator

@louis-bompart louis-bompart commented Dec 8, 2025

Usually, we use <my-cmp attr-name="['val1', 'val2']" for attributes. This one differs from the norm, let's fix that :)

KIT-5305

Copy link
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

This PR adds support for normalized JSON array input to the fieldsToIncludeInCitations property in the atomic-generated-answer component. The change allows the property to accept either a string array (new standard) or a comma-separated string (deprecated), maintaining backward compatibility while preparing for v4 where only array input will be supported.

Key changes:

  • Property type updated from string to string | string[]
  • New getCitationFieldsInputArray() helper method to handle both input formats with deprecation warning
  • Refactored getCitationFields() to delegate to the new helper

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

`Starting from Atomic v4, the "fields-to-include-in-citations" property will only accept an array of strings. Using a string value is now deprecated. Please update the value to be an array of strings. For example: fields-to-include-in-citations='["fieldA","fieldB"]'`
);
return (this.fieldsToIncludeInCitations ?? '')
.split(',')
Copy link

Copilot AI Dec 8, 2025

Choose a reason for hiding this comment

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

Missing semicolon after .split(','). This will cause a syntax error.

Suggested change
.split(',')
.split(',');

Copilot uses AI. Check for mistakes.
}

// TODO V4 (KIT-5306): Remove support for string value.
private getCitationFieldsInputArray() {
Copy link

Copilot AI Dec 8, 2025

Choose a reason for hiding this comment

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

This method should have an explicit return type annotation for type safety. Add : string[] as the return type.

Suggested change
private getCitationFieldsInputArray() {
private getCitationFieldsInputArray(): string[] {

Copilot uses AI. Check for mistakes.
Comment on lines 311 to 318
if( Array.isArray(this.fieldsToIncludeInCitations)) {
return this.fieldsToIncludeInCitations;
} else {
this.bindings.engine.logger.warn(
`Starting from Atomic v4, the "fields-to-include-in-citations" property will only accept an array of strings. Using a string value is now deprecated. Please update the value to be an array of strings. For example: fields-to-include-in-citations='["fieldA","fieldB"]'`
);
return (this.fieldsToIncludeInCitations ?? '')
.split(',')
Copy link

Copilot AI Dec 8, 2025

Choose a reason for hiding this comment

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

The deprecation warning should only be logged when a string value is actually provided. Currently, it will log even when the property is undefined. Consider adding a check:

} else if (this.fieldsToIncludeInCitations) {
  this.bindings.engine.logger.warn(
    // ... warning message
  );
  return (this.fieldsToIncludeInCitations ?? '').split(',');
} else {
  return [];
}

This prevents unnecessary warnings when the property is not set at all.

Suggested change
if( Array.isArray(this.fieldsToIncludeInCitations)) {
return this.fieldsToIncludeInCitations;
} else {
this.bindings.engine.logger.warn(
`Starting from Atomic v4, the "fields-to-include-in-citations" property will only accept an array of strings. Using a string value is now deprecated. Please update the value to be an array of strings. For example: fields-to-include-in-citations='["fieldA","fieldB"]'`
);
return (this.fieldsToIncludeInCitations ?? '')
.split(',')
if (Array.isArray(this.fieldsToIncludeInCitations)) {
return this.fieldsToIncludeInCitations;
} else if (typeof this.fieldsToIncludeInCitations === 'string') {
this.bindings.engine.logger.warn(
`Starting from Atomic v4, the "fields-to-include-in-citations" property will only accept an array of strings. Using a string value is now deprecated. Please update the value to be an array of strings. For example: fields-to-include-in-citations='["fieldA","fieldB"]'`
);
return this.fieldsToIncludeInCitations.split(',');
} else {
return [];

Copilot uses AI. Check for mistakes.

// TODO V4 (KIT-5306): Remove support for string value.
private getCitationFieldsInputArray() {
if( Array.isArray(this.fieldsToIncludeInCitations)) {
Copy link

Copilot AI Dec 8, 2025

Choose a reason for hiding this comment

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

Extra space after if keyword. Should be if( not if(.

Suggested change
if( Array.isArray(this.fieldsToIncludeInCitations)) {
if (Array.isArray(this.fieldsToIncludeInCitations)) {

Copilot uses AI. Check for mistakes.
@louis-bompart
Copy link
Collaborator Author

@copilot open a new pull request to apply changes based on the comments in this thread
Ignore the resolved conversation tho

Copy link
Contributor

Copilot AI commented Dec 8, 2025

@louis-bompart I've opened a new pull request, #6739, to work on those changes. Once the pull request is ready, I'll request review from you.

…6739)

Co-authored-by: copilot-swe-agent[bot] <[email protected]>
Co-authored-by: louis-bompart <[email protected]>
Co-authored-by: Louis Bompart <[email protected]>
Copy link
Contributor

Choose a reason for hiding this comment

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

Normally I'd say we need to adjust the unit tests accordingly, but given that the component hasn't yet been migrated I guess this will have to wait 😁

Copy link
Contributor

@lavoiesl lavoiesl left a comment

Choose a reason for hiding this comment

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

Nice use of the a TODO ticket and deprecation warning 👍🏼

Comment on lines +314 to +316
this.bindings.engine.logger.warn(
`Starting from Atomic v4, the "fields-to-include-in-citations" property will only accept an array of strings. Using a string value is now deprecated. Please update the value to be an array of strings. For example: fields-to-include-in-citations='["fieldA","fieldB"]'`
);
Copy link
Contributor

@lavoiesl lavoiesl Dec 12, 2025

Choose a reason for hiding this comment

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

Unrelated to this PR: Should we have a dedicated primitive for raising deprecations?

Here's what Rails does: https://blog.saeloun.com/2024/11/19/rails-7-1-adds-application-deprecators-method/

# 1) Define a Custom Deprecator:
# config/initializers/deprecators.rb

Rails.application.deprecators[:user_full_name] = ActiveSupport::Deprecation.new("2.0", "user_full_name")

# Here, the custom deprecator :user_full_name is defined for deprecations related to the full_name method, specifying the Rails version (2.0) and a name for context.

# 2) Use the Deprecator in Code:

class User < ApplicationRecord
  def full_name
    Rails.application.deprecators[:user_full_name].warn("The `full_name` method will be removed in the next major release.")
  end
end

Benefits:

  • Encourages defining a target version
  • Standardizes how it's reported
  • Allows telemetry to track adoption
  • Allows silencing those warnings in production use
  • Allows deduplication of warnings to avoid spamming in the case of a repeated item

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.

4 participants