镜像站点 · 本页由第三方 GitHub 只读镜像提供,非 GitHub 官方站点,不接受任何登录或凭据输入。前往 github.com
Skip to content

Fix SyntaxError on articles with hyphenated locales - #626

Merged
anubhav-intercom merged 4 commits into
masterfrom
fix-hyphenated-locale-accessors
Oct 7, 2026
Merged

anubhav-intercom merged 4 commits into
masterfrom
fix-hyphenated-locale-accessors

Conversation

@anubhav-intercom

Copy link
Copy Markdown
Contributor

Why?

Loading an article, collection or section with pt-BR, zh-CN or zh-TW translations raises SyntaxError, because a hyphen isn't valid in a Ruby method name. SyntaxError isn't caught by rescue => e, so callers can't recover from it. Also reported in:

How?

Accessors are now defined without building method source from attribute names, and hyphenated keys keep their original spelling when an object is saved back to the API.

Local test run

New spec in spec/unit/intercom/article_spec.rb fails on master and passes here. Unit suite: 270 runs, 512 assertions, 0 failures; the 3 timeout errors in client_spec.rb also occur on master.

Generated with Claude Code

anubhav-intercom and others added 2 commits October 6, 2026 16:28
Parsing an article, collection or section whose translated_content had a
locale key such as "pt-BR" or "zh-CN" raised a SyntaxError, because the key
was interpolated into a string passed to instance_eval and is not a valid
method name. The error is not a StandardError so callers could not rescue it.

Define the accessors with define_method and instance_variable_get/set
instead, normalising the instance variable name. Behaviour for ordinary
keys is unchanged.

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
Hyphenated keys such as pt-BR were emitted as pt_BR by to_hash,
to_json and to_submittable_hash.

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
levindixon
levindixon previously approved these changes Oct 7, 2026
CircleCI no longer accepts version 2 configs, so pipelines on this
repo error before any job runs and the required test checks never
report.

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
Version 2.1 rejects dots in job keys. Setting the original names on the
workflow jobs keeps the reported check names unchanged.

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
@anubhav-intercom
anubhav-intercom merged commit d0a8059 into master Oct 7, 2026
6 checks passed
@anubhav-intercom
anubhav-intercom deleted the fix-hyphenated-locale-accessors branch October 7, 2026 12:33
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.

3 participants