Server-side Remote Config: evaluate() throws SyntaxError when a custom signal regex condition uses RE2-only syntax such as (?i)
Maintainer thường phản hồi trong vòng 2 ngày
Đánh giá
- Độ khó
- 3/5
- Thời gian dự kiến
- 1-2 ngày
- Mức phù hợp với người mới
- 35/100
- Loại issue
- Lỗi
- Độ rõ ràng
- Đặc tả rõ ràng
- Mức độ hoạt động
- Đình trệ
- Công nghệ
- firebase, javascript, node.js, typescript
Hướng nghiên cứu
Start with the server-side Remote Config ConditionEvaluator and ServerTemplate.evaluate() behavior described in the issue, then inspect the existing evaluator tests. Reproduce the failure using a custom signal regex with (?i) and check how invalid patterns affect unrelated conditions and parameters. Done means evaluation does not throw and other conditions continue to work; an open linked pull request already addresses this issue.
Do mô hình lập chỉ mục viết ra từ nội dung của issue.
Mô tả
[REQUIRED] Step 2: Describe your environment
- Operating System version: Linux (aarch64)
- Firebase SDK version: firebase-admin 14.5.1 (from npm; also reproduces on current
main) - Firebase Product: remote-config (server-side templates)
- Node.js version: 24.14.1
- NPM version: 11.11.0
[REQUIRED] Step 3: Describe the problem
The condition reference documents that custom signal .matches([...]) conditions use RE2 syntax ("Uses RE2 syntax"). The server-side evaluator compiles each target with new RegExp(target). Some valid RE2 patterns are rejected by the JavaScript engine. The most common one is the inline case-insensitive flag (?i). Others are (?s) and named groups written (?P<name>...).
When a template contains such a condition, new RegExp() throws. Nothing in ConditionEvaluator catches the error, so ServerTemplate.evaluate() throws a raw SyntaxError for every evaluation context. This happens even when the user's signal value would never match that condition, and even for parameters that do not reference it. One condition therefore breaks every parameter in the template for every request.
The comment in evaluate() says it should only throw when no template is loaded, and should "return false in cases where the SDK is unsure how to evaluate the fetched template". The Go Admin SDK uses Go's regexp package, which implements the RE2 syntax that the docs specify. It evaluates the same template without error and returns false when a pattern cannot be compiled.
Steps to reproduce:
const { initializeApp } = require('firebase-admin/app');
const { getRemoteConfig } = require('firebase-admin/remote-config');
const template = {
conditions: [
{ name: 'premium_users', condition: { customSignal: {
customSignalOperator: 'STRING_CONTAINS_REGEX', customSignalKey: 'plan',
targetCustomSignalValues: ['(?i)premium'] } } },
{ name: 'beta_users', condition: { customSignal: {
customSignalOperator: 'STRING_CONTAINS_REGEX', customSignalKey: 'plan',
targetCustomSignalValues: ['beta'] } } },
],
parameters: {
show_ads: { defaultValue: { value: 'true' },
conditionalValues: { premium_users: { value: 'false' } } },
new_checkout: { defaultValue: { value: 'false' },
conditionalValues: { beta_users: { value: 'true' } } },
},
etag: 'etag-1',
version: { versionNumber: '1' },
};
const app = initializeApp({ projectId: 'demo-project' });
const st = getRemoteConfig(app).initServerTemplate({ template: JSON.stringify(template) });
for (const plan of ['Premium-Annual', 'beta-tester', 'free']) {
try {
const cfg = st.evaluate({ plan });
console.log(plan, cfg.getString('show_ads'), cfg.getString('new_checkout'));
} catch (e) {
console.log(plan, 'threw', e.constructor.name, e.message);
}
}
Actual output:
Premium-Annual threw SyntaxError Invalid regular expression: /(?i)premium/: Invalid group
beta-tester threw SyntaxError Invalid regular expression: /(?i)premium/: Invalid group
free threw SyntaxError Invalid regular expression: /(?i)premium/: Invalid group
The same template evaluated with the Go Admin SDK (v4.23.0, InitServerTemplate + Evaluate):
plan=Premium-Annual: show_ads=false new_checkout=false
plan=beta-tester: show_ads=true new_checkout=true
plan=free: show_ads=true new_checkout=false
Expected: evaluate() should not throw because of one condition. At a minimum, a pattern that the JavaScript engine cannot compile should evaluate to false, which is what the Go SDK does on a compile error. The other conditions and parameters should still be evaluated.
A fix that catches the compile error and returns false stops the outage. It does not make (?i) itself match the way RE2 does: in Node, the Premium-Annual row would still get show_ads=true. Translating RE2 inline flags into JavaScript flags could be a separate follow-up if that is wanted.
This issue was drafted with Claude Code (claude-opus-5-5); the results above are from the runs described.
- Ngôn ngữ chính
- TypeScript
- Star
- 1.8k
- Fork
- 429
- Merge trung bình
- 4 ngày 19 giờ
- Pull request đã merge (30 ngày)
- 14
Chuẩn bị môi trường
- Không có Dockerfile hay tệp Docker Compose
- Có mẫu pull request
- Đọc hướng dẫn đóng góp
Bắt đầu từ đâu
- Đọc hết issue, rồi đọc hướng dẫn đóng góp của dự án.
- Bình luận trên issue rằng bạn sẽ nhận — tránh hai người làm cùng một việc.
- Fork repository và làm thay đổi trên một nhánh.
- Mở pull request có tham chiếu số hiệu của issue.
Issue khác của firebase/firebase-admin-node
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 62/100
firebase/firebase-admin-node#3319 ·
Maintainer thường phản hồi trong vòng 2 ngày
-
getToken() replays a failed token refresh to later callers while a valid token is cachedCó thể đã có người làm @lahirumaramba đã nhận 11 ngày trước. Đang mở
Độ khó 3/5 1-2 ngày Mức phù hợp với người mới 35/100
firebase/firebase-admin-node#3234 · 2 bình luận · 1 người được giao ·
Maintainer thường phản hồi trong vòng 2 ngày
-
Misleading error message for THIRD_PARTY_AUTH_ERROR: raw "OAuth 2 access token" text surfaced instead of the APNs-specific messageCó thể đã có người làm @milcho0604 đã nhận 97 ngày trước. Đang mởapi: messaging
Độ khó 3/5 1-2 ngày Mức phù hợp với người mới 70/100
firebase/firebase-admin-node#3215 ·
Maintainer thường phản hồi trong vòng 2 ngày
-
api: messaging
Độ khó 5/5 Hơn một tuần Mức phù hợp với người mới 28/100
firebase/firebase-admin-node#3214 ·
Maintainer thường phản hồi trong vòng 2 ngày
-
[Firestore] Re-export functions from '@google-cloud/firestore/pipelines'Có thể làm lại được @jonathanedey đã nhận 140 ngày trước và không có pull request nào đang mở. Đang mởapi: firestore type: feature request
firebase/firebase-admin-node#3183 · 1 bình luận · 1 reaction · 1 người được giao ·
Maintainer thường phản hồi trong vòng 2 ngày
Tất cả issue của firebase/firebase-admin-node
Issue tương tự
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 75/100
Maintainer thường phản hồi trong vòng 1 ngày
-
ai-driven-qa bug claude Cosmetic
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 82/100
Maintainer thường phản hồi trong vòng 1 ngày
-
Domain / chatbot New
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 65/100
Inist-CNRS/lodex#3861 ·
Maintainer thường phản hồi trong vòng 1 ngày
-
area:agent-sdk area:docs documentation enhancement
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 66/100
anthropics/claude-code#110914 ·
-
area/cli platform/windows type/bug version/v2
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 70/100
anomalyco/opencode#64631 · 1 bình luận ·
Maintainer thường phản hồi trong vòng 1 ngày