Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Scrooge does not appear to honor Apache Thrift's list of reserved words #259

Open
rklancer opened this issue Feb 10, 2017 · 4 comments
Open

Comments

@rklancer
Copy link

Expected behavior

Apache Thrift defines a list of reserved words that apparently cannot be used as field identifiers: https://git-wip-us.apache.org/repos/asf?p=thrift.git;a=blob;f=compiler/cpp/src/thrift/thriftl.ll;hb=e1832c354391deb0e0ce94a62ff32e8ce1c83fd3#l273

Therefore, I expect Scrooge to fail to compile a .thrift file with a field named delete. Failing that I expect a clear warning that the thrift file may be incompatible with other Thrift implementations.

Actual behavior

We have been using a Scrooge-compiled Thrift file in a production Java system for a while:

struct ThingMessage {
  //...
  200: optional bool delete
  //...

However, we are unable to use Apache Thrift's python generator to build an ops tool to observe these messages:

thrift --gen py -I .../ThingMessage.thrift:35
[ERROR: .../ThingMessage.thrift:35] (last token was 'delete')
Cannot use reserved language keyword: "delete"
@rklancer
Copy link
Author

rklancer commented Feb 10, 2017

Smells like this could be an intentional choice, of course. Let me know.

That said, there's little or no public documentation of Thrift's reserved words, so users aren't likely to realize they're transgressing against compatibility unless the compiler either refuses to compile or at least requires them to use some kind of "--force" flag to override compatibility.

@kevinoliver
Copy link
Contributor

it'd be good if we matched apache thrift's behavior.

i suspect if we didn't give users an escape valve it'd wreck havoc on them. perhaps via a "comment" to allow specific keywords within the file?

@mosesn
Copy link
Contributor

mosesn commented May 9, 2017

@rklancer would you be open to making a PR that reserves the thrift reserved words?

finaglehelper pushed a commit that referenced this issue Aug 30, 2021
Problem:
Scrooge [[ #259 | doesn't respect the same keywords ]]
as Apache thrift. This mismatch prevents us from upgrading thrift, and it creates friction
for customers generating code from existing scrooge-compatible thrift files via apache thrift.

Solution:
Update our forbidden keywords in ThriftParser to include [[ https://github.com/apache/thrift/blob/f7e6c654bde5d9832bede2b48b460c3e1bbbbb92/doc/specs/idl.md#reserved-keywords | the keywords ]]
Apache Thrift disallows, and fix affected files.

JIRA Issues: CSL-11183

Differential Revision: https://phabricator.twitter.biz/D707116
@rtyley
Copy link

rtyley commented Jan 19, 2024

The new checks for reserved Thrift keywords introduced by 884f360:

lazy val simpleID: Parser[SimpleID] = positioned(simpleIDRegex ^^ { x =>
if (ThriftKeywords.contains(x))
throw new KeywordException(x)
SimpleID(x)
})

...do not seem to be disabled by the scroogeDisableStrict flag:

val scroogeDisableStrict = SettingKey[Boolean](
"scrooge-disable-strict",
"issue warnings on non-severe parse errors instead of aborting"
)

...just checking, was that intentional?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Development

No branches or pull requests

4 participants