Skip to content

License errors - #380

Merged
izulin merged 26 commits into
developfrom
pu/issue-306
Sep 11, 2020
Merged

izulin merged 26 commits into
developfrom
pu/issue-306

Conversation

@izulin

@izulin izulin commented Jun 4, 2020

Copy link
Copy Markdown
Contributor

Context

How has this been tested?

Types of changes

  • Bug fix (non-breaking change which fixes an issue)
  • New feature or improvement (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to not work as expected)
  • Additional language file or change to the existing one (translations)

Related issue(s):

  1. Add #LIC! error when licenseKey is invalid #306

Checklist:

  • My code follows the code style of this project,
  • My change requires a change to the documentation,
  • I described the modification in the CHANGELOG.md file.

@izulin
izulin requested a review from wojciechczerniak June 4, 2020 11:27
@izulin

izulin commented Jun 4, 2020

Copy link
Copy Markdown
Contributor Author

@wojciechczerniak how to create an engine with invalid/missing license (for testing)?

@wojciechczerniak

Copy link
Copy Markdown
Contributor

licenseKey: null or licenseKey: undefined should be missing key
licenseKey: 'blah blah' anything other than "non-commercial-and-evaluation" and "agpl-v3" will be invalid key (I assume you will not randomly generate valid license key 😉 )

@izulin

izulin commented Jun 4, 2020

Copy link
Copy Markdown
Contributor Author

@wojciechczerniak we need someone to do the missing translations for '#LIC!'

@wojciechczerniak

Copy link
Copy Markdown
Contributor

#LIC! is not translatable. It should not be available in lang files so it's not overwritable and always obvious.

Will be cool if it could have message prop with the reason why it's invalid: missing, invalid, expired.

@izulin

izulin commented Jun 4, 2020

Copy link
Copy Markdown
Contributor Author

#LIC! is not translatable. It should not be available in lang files so it's not overwritable and always obvious.

Will be cool if it could have message prop with the reason why it's invalid: missing, invalid, expired.

Having no #LIC! in translations results in compilation error.

@wojciechczerniak wojciechczerniak left a comment •

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

I can't add the comment to the file that is not a part of this PR, but it will be better to exclude LIC from translations type in index.ts and remove all the ts-ignore comments

(use Exclude utility type that is built-in TS)

export type ErrorTranslationSet = Record<Exclude<ErrorType, ErrorType.LIC>, string>

Comment thread src/i18n/languages/daDK.ts Resolved
Comment thread src/i18n/TranslationPackage.ts Resolved
Comment thread src/Serialization.ts Resolved
Comment thread src/interpreter/Interpreter.ts Resolved
Comment thread src/i18n/TranslationPackage.ts Resolved
izulin and others added 6 commits June 7, 2020 15:33
Co-authored-by: Wojciech Czerniak <wojciech.czerniak@gmail.com>
Co-authored-by: Wojciech Czerniak <wojciech.czerniak@gmail.com>
Co-authored-by: Wojciech Czerniak <wojciech.czerniak@gmail.com>
@izulin
izulin requested a review from wojciechczerniak June 7, 2020 17:23
@krzysztofspilka krzysztofspilka changed the title licence errors License errors Jun 8, 2020
Comment thread src/Cell.ts
ERROR = 'ERROR'
}

export type TranslatableErrorType = Exclude<ErrorType, ErrorType.LIC>

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Changing type for translation package was not enough? If I understood correctly ts-ignore was needed there. Do we need another type?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

yes, this propagates into Config (e.g. buildErrorMapping)

izulin and others added 2 commits June 8, 2020 23:53
Co-authored-by: Wojciech Czerniak <wojciech.czerniak@gmail.com>
@izulin

izulin commented Jun 8, 2020

Copy link
Copy Markdown
Contributor Author

@wojciechczerniak

there were some new tests merged into develop, so now there is a problem with a following:

    it('missing license key', () => {
      const engine = HyperFormula.buildFromArray([
        ['=VERSION()'],
      ], {
        licenseKey: '',
      })
  
      expect(engine.getCellValue(adr('A1'))).toEqual(`HyperFormula v${HyperFormula.version}, 3`)
    })
  
    it('invalid license key', () => {
      const engine = HyperFormula.buildFromArray([
        ['=VERSION()'],
      ], {
        licenseKey: '11111-11111-11111-11111-11111',
      })
  
      expect(engine.getCellValue(adr('A1'))).toEqual(`HyperFormula v${HyperFormula.version}, 4`)
    })

since without proper licence getCellValue returns error. What should we do?

@wojciechczerniak

Copy link
Copy Markdown
Contributor

@izulin

since without proper licence getCellValue returns error. What should we do?

It should return the expected value so we can check why the #LIC! error occurs

@izulin

izulin commented Jun 9, 2020

Copy link
Copy Markdown
Contributor Author

@izulin

since without proper licence getCellValue returns error. What should we do?

It should return the expected value so we can check why the #LIC! error occurs

There might not be an easy way of achieving this. First, any formula evaluates to error, second, any value extracted from getCellValue becomes error.

@wojciechczerniak

Copy link
Copy Markdown
Contributor

There might not be an easy way of achieving this. First, any formula evaluates to error, second, any value extracted from getCellValue becomes error.

Maybe we should simplify this PR then? Return the #LIC! only then a function is used and it's not a VERSION. We don't need an error in every single cell. WDYT? Can we keep it simple with a single condition?

@izulin

izulin commented Jun 9, 2020

Copy link
Copy Markdown
Contributor Author

There might not be an easy way of achieving this. First, any formula evaluates to error, second, any value extracted from getCellValue becomes error.

Maybe we should simplify this PR then? Return the #LIC! only then a function is used and it's not a VERSION. We don't need an error in every single cell. WDYT? Can we keep it simple with a single condition?

What about getCellValue?

@izulin

izulin commented Jun 9, 2020

Copy link
Copy Markdown
Contributor Author

There might not be an easy way of achieving this. First, any formula evaluates to error, second, any value extracted from getCellValue becomes error.

Maybe we should simplify this PR then? Return the #LIC! only then a function is used and it's not a VERSION. We don't need an error in every single cell. WDYT? Can we keep it simple with a single condition?

That would mean that you can use the spreadsheet in some limited form (no functions, just arithmetics) without the license.

@izulin

izulin commented Jun 18, 2020

Copy link
Copy Markdown
Contributor Author

@wojciechczerniak any decision made on how do we proceed with this task?

@wojciechczerniak wojciechczerniak self-assigned this Jun 22, 2020
@wojciechczerniak

Copy link
Copy Markdown
Contributor

@wojciechczerniak any decision made on how do we proceed with this task?

Sorry, not yet. I didn't forget. The North remembers! ⚔️ 🐺

We're quite busy, but I will get back to this issue ASAP

@wojciechczerniak wojciechczerniak left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Thanks 👍

Note for future: we've agreed that it's a good idea to simplify the code and display the #LIC! error just for function calls (other than protectedFunctions). Simple arithmetic ops should work as a basic/demo feature. This will fulfill the requirements to verify the license for advanced calculations and avoid checking the license in multiple places, reducing code complexity and limiting impacto on the performance

@izulin
izulin merged commit 0bbe618 into develop Sep 11, 2020
@izulin
izulin deleted the pu/issue-306 branch September 11, 2020 12:19
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.

2 participants