Skip to content

Conversation

@dan-s1
Copy link
Contributor

@dan-s1 dan-s1 commented Feb 12, 2026

Summary

NIFI-15596
The change involved changing the regular expression to allow for a positive decimal number with or without a leading 0 and to parse the number as a float and not an integer since a decimal without a leading integer greater than zero will parse as zero.

Tracking

Please complete the following tracking steps prior to pull request creation.

Issue Tracking

Pull Request Tracking

  • Pull Request title starts with Apache NiFi Jira issue number, such as NIFI-00000
  • Pull Request commit message starts with Apache NiFi Jira issue number, as such NIFI-00000
  • Pull request contains commits signed with a registered key indicating Verified status

Pull Request Formatting

  • Pull Request based on current revision of the main branch
  • Pull Request refers to a feature branch with one commit containing changes

Verification

Please indicate the verification steps performed prior to pull request creation.

Build

  • Build completed using ./mvnw clean install -P contrib-check
    • JDK 21
    • JDK 25

Licensing

  • New dependencies are compatible with the Apache License 2.0 according to the License Policy
  • New dependencies are documented in applicable LICENSE and NOTICE files

Documentation

  • Documentation formatting appears as expected in rendered files

@dan-s1 dan-s1 requested review from mcgilman and rfellows February 12, 2026 20:21
@dan-s1 dan-s1 added bug ui Pull requests for work relating to the user interface labels Feb 12, 2026
@mcgilman
Copy link
Contributor

Will review...

Copy link
Contributor

@mcgilman mcgilman left a comment

Choose a reason for hiding this comment

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

Thanks for the PR @dan-s1! Noted one item below. Also it would be good to include some new test cases for this. Here are some test cases that could be added to the corresponding spec.

    describe('isExpirationConfigured', () => {
        it('should return true when expiration is a positive integer duration', () => {
            const connection = { flowFileExpiration: '30 sec' };

            const result = (service as any).isExpirationConfigured(connection);

            expect(result).toBe(true);
        });

        it('should return false when expiration is zero', () => {
            const connection = { flowFileExpiration: '0 sec' };

            const result = (service as any).isExpirationConfigured(connection);

            expect(result).toBe(false);
        });

        it('should return true when expiration is a decimal with leading zero', () => {
            const connection = { flowFileExpiration: '0.5 sec' };

            const result = (service as any).isExpirationConfigured(connection);

            expect(result).toBe(true);
        });

        it('should return true when expiration is a decimal without leading integer', () => {
            const connection = { flowFileExpiration: '.5 sec' };

            const result = (service as any).isExpirationConfigured(connection);

            expect(result).toBe(true);
        });

        it('should return false when flowFileExpiration is null', () => {
            const connection = { flowFileExpiration: null };

            const result = (service as any).isExpirationConfigured(connection);

            expect(result).toBe(false);
        });

        it('should return false when flowFileExpiration is undefined', () => {
            const connection = { flowFileExpiration: undefined };

            const result = (service as any).isExpirationConfigured(connection);

            expect(result).toBe(false);
        });

        it('should return false when expiration has no numeric value', () => {
            const connection = { flowFileExpiration: 'sec' };

            const result = (service as any).isExpirationConfigured(connection);

            expect(result).toBe(false);
        });

        it('should return true when expiration is a large integer duration', () => {
            const connection = { flowFileExpiration: '3600 sec' };

            const result = (service as any).isExpirationConfigured(connection);

            expect(result).toBe(true);
        });

        it('should return false when expiration is zero decimal', () => {
            const connection = { flowFileExpiration: '0.0 sec' };

            const result = (service as any).isExpirationConfigured(connection);

            expect(result).toBe(false);
        });
    });

const match: string[] = connection.flowFileExpiration.match(/^(\d*\.?\d+).*/);
if (match !== null && match.length > 0) {
if (parseInt(match[0], 10) > 0) {
if (parseFloat(match[0]) > 0) {
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
if (parseFloat(match[0]) > 0) {
if (parseFloat(match[1]) > 0) {

I believe we should be referencing the capture group intentionally instead of relying on parseFloat implementation that would drop the secs portion. I understand this aspect isn't modified or new in this PR but would be good to improve here.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@mcgilman I appreciate you giving me the sample unit tests to write. I have no experience with TypeScript so getting examples of what to write helps a whole lot. I added one test to in addition to the ones you gave me when the leading number of the decimal is greater than 0.

Copy link
Contributor Author

@dan-s1 dan-s1 Feb 12, 2026

Choose a reason for hiding this comment

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

@mcgilman Now that the regular expression is preciser, is it even necessary to also call parseFloat?

…t to allow the "FlowFile Expiration Indicator" icon to be displayed when value is a decimal without a leading integer or when leading integer is 0.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug ui Pull requests for work relating to the user interface

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants