[Bug] [BanyanDB] MCP server ignores .env values and silently accepts malformed numeric/TRANSPORT settings
Maintainer thường phản hồi trong vòng 1 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ệ
- node.js, typescript
- Lĩnh vực
- backend
Hướng nghiên cứu
Start in mcp/src/config.ts and mcp/src/index.ts, where configuration is read and .env is loaded; then inspect the MCP tests and docs/operation/mcp/setup.md mentioned in the issue. Reproduce the three cases from the issue and check how the existing MCP_PORT range validation reports errors. Done means .env values are applied, malformed numeric values and unsupported TRANSPORT values fail clearly, and tests cover each case; a pull request is already open.
Do mô hình lập chỉ mục viết ra từ nội dung của issue.
Mô tả
Search before asking
- I had searched in the issues and found no similar issues.
Apache SkyWalking Component
BanyanDB (apache/skywalking-banyandb)
What happened
While setting up the BanyanDB MCP server (mcp/, main at adc78b88) I found three config problems. All are silent: the server starts, but with values the user didn't ask for.
- Values in
.envare ignored.src/index.tscallsdotenv.config()in its body, butsrc/config.tsreadsprocess.envat module load, and ES module imports run first. By the time.envis loaded, every exported config value is already fixed. - Numeric settings are parsed leniently.
parseIntstops at the first non-digit, so units or typos are cut off without an error:MCP_MAX_BODY_BYTES=1MiB→ 1 byte,MCP_RATE_LIMIT_WINDOW_MS=60s→ 60 ms,MCP_PORT=3000abc→ 3000. TRANSPORTisn't validated.index.tsonly checksTRANSPORT === 'http', soHTTP,Httpor a typo silently falls back to stdio.
What you expected to happen
Values from .env are applied, and invalid values fail at startup with a clear error. The code already does this for an out-of-range MCP_PORT and for values <= 0, so a value like "1MiB" or "HTTP" should be rejected the same way instead of being silently changed.
How to reproduce
In mcp/ on main (adc78b88):
# problems 2 and 3
cat > _check1.mts <<'EOF'
const c = await import('./src/config.ts');
console.log({ MCP_PORT: c.MCP_PORT, MCP_MAX_BODY_BYTES: c.MCP_MAX_BODY_BYTES, MCP_RATE_LIMIT_WINDOW_MS: c.MCP_RATE_LIMIT_WINDOW_MS, TRANSPORT: c.TRANSPORT });
EOF
MCP_PORT=3000abc MCP_MAX_BODY_BYTES=1MiB MCP_RATE_LIMIT_WINDOW_MS=60s TRANSPORT=HTTP npx tsx _check1.mts
Output:
{ MCP_PORT: 3000, MCP_MAX_BODY_BYTES: 1, MCP_RATE_LIMIT_WINDOW_MS: 60, TRANSPORT: 'HTTP' }
# problem 1 (same import order as src/index.ts)
printf 'MCP_PORT=4555\nTRANSPORT=http\n' > /tmp/test.env
cat > _check2.mts <<'EOF'
import dotenv from 'dotenv';
import { MCP_PORT, TRANSPORT } from './src/config.ts';
dotenv.config({ path: '/tmp/test.env', quiet: true });
console.log({ config: { MCP_PORT, TRANSPORT }, env: { MCP_PORT: process.env.MCP_PORT, TRANSPORT: process.env.TRANSPORT } });
EOF
npx tsx _check2.mts
Output:
{ config: { MCP_PORT: 3000, TRANSPORT: 'stdio' }, env: { MCP_PORT: '4555', TRANSPORT: 'http' } }
Anything else
Happens every time. A possible fix, contained to mcp/src:
- load .env before config.ts is evaluated (e.g.
import 'dotenv/config'as the first import in index.ts, or call dotenv.config() at the top of config.ts); - parse integers strictly (the whole string must be digits) in parsePositiveInteger and for MCP_PORT;
- accept only stdio / http for TRANSPORT (case-insensitive) and fail otherwise;
- unit tests for each case, and a note about .env in docs/operation/mcp/setup.md.
Related history: the review of apache/skywalking-banyandb#1010 noted that a non-numeric MCP_PORT becomes NaN and that the docs mentioned streamable-http while the code only accepts http; #1036 then added the MCP_PORT range check. The cases above (partial numbers like "3000abc"/"1MiB", "HTTP" in a different case, and .env being loaded after config.ts) are still open on main.
Are you willing to submit a pull request to fix on your own?
- Yes I am willing to submit a pull request on my own!
Code of Conduct
- I agree to follow this project's Code of Conduct
- Ngôn ngữ chính
- Java
- Star
- 25k
- Fork
- 6.6k
- Merge trung bình
- 12 giờ 41 phút
- Pull request đã merge (30 ngày)
- 48
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 apache/skywalking
-
[Bug] [BanyanDB] MCP HTTP server rejects a lowercase "bearer" Authorization schemeCó thể đã có người làm @UchihaIthachi đã nhận hôm nay. Đang mởbug database
apache/skywalking#14199 · 1 người được giao ·
Maintainer thường phản hồi trong vòng 1 ngày
-
[Bug] Standalone multi-group Measure aggregation returns one row per groupCó thể đã có người làm @hanahmily đã nhận 1 ngày trước. Đang mởbug database
apache/skywalking#14198 · 2 người được giao ·
Maintainer thường phản hồi trong vòng 1 ngày
-
[Bug] BanyanDB trace block metadata format changed in 0.11 without a file format version bumpCó thể đã có người làm @hanahmily đã nhận 11 ngày trước. Đang mởbug database
apache/skywalking#14169 · 1 bình luận · 1 người được giao ·
Maintainer thường phản hồi trong vòng 1 ngày
-
chore CLI database
Độ khó 5/5 Hơn một tuần Mức phù hợp với người mới 25/100
apache/skywalking#14168 · 2 bình luận ·
Maintainer thường phản hồi trong vòng 1 ngày
-
[BanyanDB] Stream write callback reports success for events it did not storeCó thể làm lại được Pull request cho issue này đã bị đóng mà không được merge. Đang mở
Độ khó 4/5 3-5 ngày Mức phù hợp với người mới 48/100
apache/skywalking#14158 · 2 bình luận ·
Maintainer thường phản hồi trong vòng 1 ngày
Tất cả issue của apache/skywalking
Issue tương tự
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 77/100
NationalSecurityAgency/ghidra#10149 ·
Maintainer thường phản hồi trong vòng 2 ngày
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 90/100
yegor256/antlr2ebnf-maven-plugin#155 ·
Maintainer thường phản hồi trong vòng 1 ngày
-
account bug exercise lecture programming user interface
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 72/100
ls1intum/Artemis#14512 · 1 bình luận ·
Maintainer thường phản hồi trong vòng 1 ngày
-
kind:bug priority:major
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 76/100
Maintainer thường phản hồi trong vòng 1 ngày
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 76/100
swiftlang/swift-java#955 ·
Maintainer thường phản hồi trong vòng 1 ngày